Skip to content

chore: adding better bootstrap support for react sdk#1194

Merged
joker23 merged 1 commit intomainfrom
skz/sdk-1992/react-bootstrapping
Mar 23, 2026
Merged

chore: adding better bootstrap support for react sdk#1194
joker23 merged 1 commit intomainfrom
skz/sdk-1992/react-bootstrapping

Conversation

@joker23
Copy link
Copy Markdown
Contributor

@joker23 joker23 commented Mar 18, 2026

This PR will allow developers to directly set bootstrap data on the sdk provider.

I think this is helpful in order to reasonably preserve the non-deferred start case.


Open with Devin

Note

Medium Risk
Touches provider initialization behavior by altering the client.start() options, which could affect startup/flag hydration if callers relied on previous startOptions semantics.

Overview
Adds a first-class bootstrap option to createLDReactProvider, and when auto-starting it now merges that value into the client.start() options (overriding any startOptions.bootstrap).

Updates unit coverage to assert the new merge/precedence behavior, and extends the migration docs to explain how to pass bootstrap data in the new SDK.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

@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

github-actions bot commented Mar 18, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

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

devin-ai-integration[bot]

This comment was marked as resolved.

@joker23 joker23 force-pushed the skz/sdk-1992/react-bootstrapping branch from 2c0361a to e2f975f Compare March 18, 2026 15:33
@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented Mar 18, 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!

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

@joker23 joker23 marked this pull request as ready for review March 18, 2026 19:02
@joker23 joker23 requested a review from a team as a code owner March 18, 2026 19:02
* `bootstrap` and `startOptions.bootstrap` are provided, this top-level value takes
* precedence.
*/
bootstrap?: unknown;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


const client = createClient(clientSideID, context, ldOptions);

if (!deferInitialization) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I figured if users are deferring start then they will need to provide their own start options. We may need to call this out in docs somewhere.

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 found 1 new potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment on lines 123 to 126
if (!deferInitialization) {
client.start(startOptions);
const effectiveStartOptions = bootstrap ? { ...startOptions, bootstrap } : startOptions;
client.start(effectiveStartOptions);
}
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot Mar 18, 2026

Choose a reason for hiding this comment

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

🟡 Bootstrap data is silently discarded when deferInitialization: true

When a user passes { bootstrap: myData, deferInitialization: true } to createLDReactProvider, the bootstrap value is destructured from options at line 119 but never used because the if (!deferInitialization) block (lines 123-126) is skipped entirely. Since createLDReactProvider returns a React.FC (not the client), the user has no way to recover the lost bootstrap data. The only way to later call start() is through the useLDClient() hook (packages/sdk/react/src/client/hooks/useLDClient.ts:14), but the bootstrap data from the original options is inaccessible at that point. The API happily accepts this combination without any warning, silently discarding the user's bootstrap data.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is fine as we should have it documented that if developers decide to defer initialization then they are responsible for starting the client however they want.

@joker23 joker23 force-pushed the skz/sdk-1992/react-bootstrapping branch from 631cb11 to 3cf06dc Compare March 20, 2026 21:57
@joker23 joker23 force-pushed the skz/sdk-1992/react-bootstrapping branch from 3cf06dc to da8201d Compare March 23, 2026 14:48
@joker23 joker23 merged commit c51db83 into main Mar 23, 2026
43 checks passed
@joker23 joker23 deleted the skz/sdk-1992/react-bootstrapping branch March 23, 2026 17:16
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.

2 participants