WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Dec 24, 2025

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

sdk-1676

Describe the solution you've provided

  • Added a warning message for when async storage is not found and is being mocked.
  • Added tests to verify behavior with custom and default storage implementations.
    Provide a clear and concise description of what you expect to happen.

Note

Introduces a logger-aware AsyncStorage initialization with a fallback and verifies storage selection behavior.

  • Refactors ConditionalAsyncStorage into getAsyncStorage(logger) that logs a warning and returns a mock when @react-native-async-storage/async-storage is unavailable
  • Updates PlatformStorage to initialize via getAsyncStorage and proxy get/set/clear to the resolved instance
  • Adds ReactNativeLDClient.storage.test.ts to assert use of custom storage, absence of warnings, and default PlatformStorage instantiation and method calls when no custom storage is provided
  • Minor comment/whitespace cleanup in EventSource.ts

Written by Cursor Bugbot for commit 3bc8c25. This will update automatically on new commits. Configure here.

- Added a warning message for when async storage is not found and is being mocked.
- Added tests to verify behavior with custom and default storage implementations.
@joker23 joker23 requested a review from a team as a code owner December 24, 2025 18:58
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25394 bytes
Compressed size limit: 26000
Uncompressed size: 124693 bytes

@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 23135 bytes
Compressed size limit: 25000
Uncompressed size: 80393 bytes

return require('@react-native-async-storage/async-storage').default;
} catch (e) {
// Use a mock if async-storage is unavailable
logger.warn('AsyncStorage is not available, using a mock implementation.');
Copy link
Member

Choose a reason for hiding this comment

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

I think we may want to consider not using mock. It doesn't convey what will actually happen.

I think we want to do a few things:

  • Make it clear that there will be no persistence of generated keys or context cache.
  • Make it easy to understand what is required to fix it.

I am also concerned implementation wise. It seems like even without storage we should be keeping things in memory to be stable for the application session. (This is a pre-existing problem we could have in a different PR.)

Also, will these be called even if RNStorage is specified? I feel like it probably would be, but wouldn't matter in that case.

Copy link
Contributor Author

@joker23 joker23 Jan 5, 2026

Choose a reason for hiding this comment

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

Ah yea, it would be good to be able to fallback to inmemory context storage. I can create a work item for that.

If a custom storage is provided, then this line should not run

storage: storage ?? new PlatformStorage(logger),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the message wording, how about:

AsyncStorage is not available, generate keys and context caches will not be persisted. Please see https://launchdarkly.github.io/js-core/packages/sdk/react-native/docs/interfaces/LDOptions.html#storage for more information.

Additionally, I think we can put more details in the documentation with links to the default implementation for https://github.com/react-native-async-storage/async-storage

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good.

generate -> generated

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.

3 participants