Repository navigation
fix(browser): cap persisted event queue size - #1410
Open
sunitaprajapati89 wants to merge 1 commit into
Open
sunitaprajapati89 wants to merge 1 commit into
sunitaprajapati89 wants to merge 1 commit into
Conversation
Limit each persisted queue to 500 items (dropping the oldest) and prune the persisted `seen` map to the retained items. Queues for destinations that never become ready (e.g. blocked by an ad blocker) were never flushed and grew across page loads until they exhausted the localStorage quota. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: a03647d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🌙 Earthly Lunar❌ 1 Failing
✅ 2 Passing |
Codecov Report✅ All modified and coverable lines are covered by tests. Please upload reports for the commit a03647d to get more accurate results. Additional details and impacted files@@ Coverage Diff @@
## master #1410 +/- ##
==========================================
+ Coverage 91.59% 91.60% +0.01%
==========================================
Files 128 128
Lines 4162 4169 +7
Branches 1036 1037 +1
==========================================
+ Hits 3812 3819 +7
Misses 350 350
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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
Fixes #1261.
Persisted queues for destinations that never become ready (e.g. blocked by an ad blocker) are never flushed. Because
maxAttemptsonly increases on push/retry, buffered events stay at 1 attempt and are never dropped. On eachpagehidethey are written tolocalStorage, reloaded on the next visit, and written again, so the queue grows across visits until it exhausts the quota (5MB+ in the reported cases).Changes
MAX_PERSISTED_ITEMS = 500, dropping the oldest items first. Items already in storage are now ordered before in-memory ones so the newest survive.seenmap to the IDs of the items that were kept, so it can't grow unbounded either.seenpruned) and a changeset.The fix is scoped to the browser
PersistedPriorityQueue; the sharedPriorityQueuein@segment/analytics-coreis untouched.Notes
QuotaExceededErroron writes (separate branch/PR); the two will touch the same lines inpersisted.ts.Testing
tsc --noEmit, eslint and prettier clean for the changed files🤖 Generated with Claude Code