-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Description
The _saveFailedLogsToStorage method in EventLogger.js caps new events per flush to MAX_FAILED_LOGS (500), but does not cap the total accumulated events. This allows localStorage to grow indefinitely when network requests consistently fail.
Steps to Reproduce
- Configure environment where Statsig's
/v1/rgstrendpoint consistently fails (e.g., ad blocker, corporate firewall) - Use the application normally, triggering gate checks and exposure events
- Each failed flush appends up to 500 events to existing stored events
- Over time,
statsig.failed_logs.*grows to thousands of events
Current Behavior
_saveFailedLogsToStorage(events) {
while (events.length > MAX_FAILED_LOGS) { // Only caps NEW events
events.shift();
}
const savedEvents = this._getFailedLogsFromStorage(storageKey); // No limit
_setObjectInStorage(storageKey, [...savedEvents, ...events]); // And keeps growing
}
Expected Behavior
The total accumulated events should be capped, not just new events per flush:
_saveFailedLogsToStorage(events) {
const savedEvents = this._getFailedLogsFromStorage(storageKey);
const combined = [...savedEvents, ...events];
if (combined.length > MAX_FAILED_LOGS) {
combined.splice(0, combined.length - MAX_FAILED_LOGS);
}
_setObjectInStorage(storageKey, combined);
}
Impact
- localStorage exhaustion: Users can accumulate events until localStorage is full
- QuotaExceededError: Breaks applications when localStorage limit is reached
- Performance: Page load attempts to retry thousands of failed events
- User experience: Application may crash or behave unexpectedly
Environment
@statsig/client-core: 3.26.0@statsig/js-client: 3.26.0- Browser: Chrome/Firefox/Safari (all affected)
stacylondon
Metadata
Metadata
Assignees
Labels
No labels