-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Describe the bug
If the browser's localstorage is at capacity (e.g. in chrome localstorage is capped at 5MB), then attempting to set an item in it will fail with a QuotaExceededError
. Some parts of the LaunchDarkly SDK catch and disregard this error:
Lines 507 to 509 in 6315c36
if (useLocalStorage && store) { | |
return store.saveFlags(flags).catch(() => null); // disregard errors | |
} else { |
But the diagnostics section does not catch the error:
js-sdk-common/src/diagnosticEvents.js
Lines 124 to 129 in 6315c36
function saveProperties() { | |
if (platform.localStorage) { | |
const props = { ...acc.getProps() }; | |
platform.localStorage.set(localStorageKey, JSON.stringify(props), () => {}); | |
} | |
} |
Which causes the browser to report an unhandled promise rejection. We noticed this because our frontend error tracking tool is filling up with unhandled promise rejection errors from the LaunchDarkly SDK.
Expected behavior
The diagnostics code should call .catch()
on the promise, and disregard (or handle) any errors encountered while storing this information.