Fix unbounded memory growth in DocCache#2
Merged
mattpodwysocki merged 1 commit intomainfrom Mar 6, 2026
Merged
Conversation
jussi-sa
previously approved these changes
Mar 6, 2026
The merge-base changed after approval.
jussi-sa
approved these changes
Mar 6, 2026
jussi-sa
previously approved these changes
Mar 6, 2026
ctufts
previously approved these changes
Mar 6, 2026
The merge-base changed after approval.
jussi-sa
previously approved these changes
Mar 6, 2026
The merge-base changed after approval.
jussi-sa
previously approved these changes
Mar 6, 2026
The merge-base changed after approval.
ctufts
previously approved these changes
Mar 6, 2026
jussi-sa
previously approved these changes
Mar 6, 2026
- Add 512-entry LRU eviction cap - Add 2 MB per-entry size limit (oversized responses silently skipped) - Add 50 MB total cache size cap with oldest-first eviction - Normalize cache keys: strip query params and hash fragments to prevent cache-busting strings from inflating entry count - Add 22 unit tests covering all new cache invariants Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
5f62b89 to
fc70b68
Compare
jussi-sa
approved these changes
Mar 6, 2026
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.
Summary
The
DocCacheclass used an unconstrainedMapwith no limits on the number of entries, size per entry, or total memory used. A client providing many unique URLs (e.g. with arbitrary query parameters) could grow the cache without bound, eventually causing memory exhaustion.https://docs.mapbox.com/page?bust=1andhttps://docs.mapbox.com/page?bust=2map to the same cache entryTest plan
test/utils/docCache.test.tscovering all invariants🤖 Generated with Claude Code