Skip to content

Library does not catch errors when changing localstorage #54

@BRMatt

Description

@BRMatt

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:

js-sdk-common/src/index.js

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions