Skip to content

fix(electron-sdk): localstorage indexing#1262

Open
joker23 wants to merge 4 commits intomainfrom
skz/sdk-2156/electron-localstorage
Open

fix(electron-sdk): localstorage indexing#1262
joker23 wants to merge 4 commits intomainfrom
skz/sdk-2156/electron-localstorage

Conversation

@joker23
Copy link
Copy Markdown
Contributor

@joker23 joker23 commented Apr 10, 2026

This PR will fix the localstorage indexing by removing the previous nested structure:

ldcache-{credential}

To:

ldcache

The new structure is more consistent with other SDKs by calculating the storage index purely out of the context canonical keys.

This PR will also serialize the write to this cache so that multiple instances of this SDK could exist.


Note

Medium Risk
Changes how cached flag/context data is persisted (single shared ldcache file and new async flush behavior), which can affect multi-client behavior and durability on disk-write failures.

Overview
Storage/indexing behavior changes. ElectronStorage no longer namespaces cache files by credential; it now always uses a single ldcache file under Electron userData and is exposed via a singleton getElectronStorage() used by ElectronPlatform/ElectronClient.

Write/flush semantics updated. set/clear now update the in-memory cache immediately and enqueue an async flush to disk (logging Error flushing storage to disk on failure), rather than only mutating cache after a successful write.

Tests/contract tests adjusted. Adds maxCachedContexts coverage (eviction and disabled caching when 0), updates ElectronStorage tests for new file path and flush behavior, and resets the storage singleton between contract-test clients via internal resetElectronStorage (also removing the contract-test singleton capability flag).

Reviewed by Cursor Bugbot for commit f084d37. Bugbot is set up for automated code reviews on this repo. Configure here.


Open with Devin

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25661 bytes
Compressed size limit: 29000
Uncompressed size: 126143 bytes

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179348 bytes
Compressed size limit: 200000
Uncompressed size: 830127 bytes

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 31736 bytes
Compressed size limit: 34000
Uncompressed size: 112937 bytes

@github-actions
Copy link
Copy Markdown
Contributor

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 37181 bytes
Compressed size limit: 38000
Uncompressed size: 204409 bytes

@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented Apr 10, 2026

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23 joker23 force-pushed the skz/sdk-2156/electron-localstorage branch from 01d152b to 1ba2c69 Compare April 10, 2026 16:12
@joker23 joker23 force-pushed the skz/sdk-2156/electron-localstorage branch from 1ba2c69 to b327868 Compare April 10, 2026 16:48
@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented Apr 10, 2026

@cursor review

cursor[bot]

This comment was marked as resolved.

@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented Apr 10, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f084d37. Configure here.

@joker23 joker23 marked this pull request as ready for review April 10, 2026 19:33
@joker23 joker23 requested a review from a team as a code owner April 10, 2026 19:33
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant