fix: prevent storage quota errors during event logging#1286
Conversation
PR SummaryMedium Risk Overview Vault layer now treats reads/writes as best-effort: Offline batch persistence routes queue saves through Persistence wraps Regression tests cover vault outcomes, persistence save failures, batch trimming, unavailable storage, and null retrieve during upload. Reviewed by Cursor Bugbot for commit fdbe5d6. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fdbe5d6. Configure here.
| if (isEmpty(batches)) { | ||
| this.batchVault.store([]); | ||
| this.batchesQueuedForProcessing = []; | ||
| return; |
There was a problem hiding this comment.
Failed offline clears duplicate events
High Severity
After batches or session events are uploaded, the SDK clears offline vaults via purge() and store([]), but those calls now swallow storage errors and callers ignore failure results. If local or session storage is not actually cleared, the next prepareAndUpload reloads the same payloads and can send duplicate analytics events.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit fdbe5d6. Configure here.
| // Could not persist any batches; retain them in memory to retry later. | ||
| this.mpInstance.Logger.warning( | ||
| 'Offline batch storage is unavailable. Retaining batches in memory.' | ||
| ); |
There was a problem hiding this comment.
Wrong warning after quota trim fails
Low Severity
When every batchVault.store attempt returns QuotaExceeded after trimming down to a single batch, the loop exits without hitting the Unavailable branch, but the code still logs that offline batch storage is unavailable. That mislabels a pure quota problem and can mislead monitoring or debugging.
Reviewed by Cursor Bugbot for commit fdbe5d6. Configure here.
|
Closing in favor of #1287 |
|




Background
QuotaExceededErrorsurfacing from the synchronous commerce event path, includingeCommerce.logImpression.What Has Changed
savePersistence()localStorage writes so quota failures are logged without throwing.dist/mparticle.js.Verification
npm run build:iifenpm run build:test-bundlenpm run test:jestnpx karma start test/karma.config.js --browsers ChromeHeadless --single-runScreenshots/Video
Checklist