Skip to content

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Nov 25, 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

Describe the solution you've provided

This PR will:

  1. Make it so that a client in FDv2 will only report intialized when it gets a basis + valid selector. This will align the behavior better with the FDv2 initializer specs.
  2. Updated the docs for the custom datasystem options with an example for clarity

Note

FDv2 now calls the initialization callback only when payload.state is non-empty, with tests added, and docs updated with an example for custom data source options.

  • Data sources:
    • In createPayloadListenerFDv2, replace basisReceived with initializedCallback and invoke it only when payload.state !== '' during applyChanges.
  • Tests:
    • Update createPayloadListenersFDv2.test.ts to use initializedCallback and assert conditional invocation for non-empty vs empty state; keep existing behavior checks for basis/updates.
  • Docs:
    • Expand JSDoc for CustomDataSourceOptions in LDDataSystemOptions.ts with @experimental note and a usage example mirroring default standard options.

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

@joker23 joker23 requested a review from a team as a code owner November 25, 2025 22:03
@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: 17636 bytes
Compressed size limit: 20000
Uncompressed size: 90259 bytes

@github-actions
Copy link
Contributor

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

// NOTE: this is a hack right now. The only condition that we will consider a valid basis
// is when there is a valid selector. Currently, the only data source that does not have a
// valid selector is the file data initializer, which will have a blank selector.
basisReceived();
Copy link
Member

Choose a reason for hiding this comment

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

Would the FDv2 fallback also not have a selector? I may just not know how that part works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my understanding here, the basis can be consumed without a selector, however that would not be considered a successful initialization from this particular initializer. I think this function might not be named correctly here as from the invocation it is simply a success callback (

payloadListener = createPayloadListener(dataSourceUpdates, logger, initSuccess);
). @tanderson-ld thoughts?

Copy link
Contributor

@tanderson-ld tanderson-ld Dec 8, 2025

Choose a reason for hiding this comment

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

I agree there is a bug in the code before this PR as even when payload.basis is false, basisReceived is called.

LDClientImpl is passing in a function called initSuccess. I think at that time I had thought getting a basis (independent of selector) was sufficient to consider it initialized. This would be my thinking at the time since I thought this code path was only hit when basis == true.

Since Casey's requirement is "Basis with a Payload Selector.", should this logic be updated to ensure basis is also true when selector is not null?

The name basisRecieved in basisReceived: VoidFunction = () => {} parameter may need to be adjusted.

@joker23 joker23 requested a review from tanderson-ld December 5, 2025 18:25
this commit also changes the initialization callback funciton to `initializedCallback` from `basisRecieved` to be more clear on what the callback is for.
@joker23 joker23 requested a review from kinyoklion December 8, 2025 16:08
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.

4 participants