Repository navigation
fix(server): stop rate limiting page and folder reads as writes - #217
Merged
Merged
Conversation
fileOperationLimiter (30/min) was mounted on all of /api/pages and /api/folders, so every read shared the write budget and writes counted twice. Normal browsing hit 429 and the client showed 'Failed to load pages from folder'. Each route now has one limiter: readLimiter for reads, fileOperationLimiter for writes. GET /api/folders gets readLimiter, as it had no route-level limiter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When you click around the site, it sometimes shows Failed to load pages from folder: Work.
server/src/index.tsmountedfileOperationLimiter(30 requests per minute) on all of/api/pagesand/api/folders. Because of this:fileOperationLimiter.Normal browsing got HTTP 429. The client only checks for 401, so it showed a general error.
Fix
Each route now has exactly one limiter:
GET)readLimiterPOST/PUT/DELETE)fileOperationLimiterfileOperationLimiterfrom the/api/pagesand/api/foldersmounts.readLimitertoGET /api/folders. It was the only route without a route-level limiter.Testing
npm run build(server): passesnpm test(server): 106/106 passThe limiters are skipped when
NODE_ENV=test, so the tests do not cover the limits. To test by hand: click quickly through more than 30 folders or pages in one minute. You should not see the error.