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

Gate FDv2 basis readiness to only trigger when a non-empty state is present; update tests accordingly and add @experimental docs plus example for custom data source options.

  • Data sources:
    • In src/data_sources/createPayloadListenerFDv2.ts, wrap the applyChanges readiness callback to invoke basisReceived() only when payload.state is non-empty, aligning initializer readiness with valid selector presence.
  • Tests:
    • Update __tests__/data_sources/createPayloadListenersFDv2.test.ts to use toHaveBeenCalledWith and expect the third applyChanges arg as expect.any(Function); adjust logger expectations.
  • Docs/Types:
    • In src/api/options/LDDataSystemOptions.ts, mark CustomDataSourceOptions as @experimental and add a concise example demonstrating initializers and synchronizers configuration.

Written by Cursor Bugbot for commit 935b994. 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?

@joker23 joker23 requested a review from tanderson-ld December 5, 2025 18:25
},
},
basisReceived,
expect.any(Function),
Copy link

Choose a reason for hiding this comment

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

Bug: New conditional logic in callback lacks test coverage

The tests were changed from verifying that basisReceived is passed directly to applyChanges to using expect.any(Function), but there's no test that verifies the new conditional behavior. The key new logic (if (payload.state !== '') determines whether basisReceived() is called) is not covered by any test. The tests don't verify that basisReceived is actually invoked when state is non-empty, nor that it's skipped when state is empty (for file data initializer scenarios). This means the core fix described in the PR could regress without test detection.

Additional Locations (1)

Fix in Cursor Fix in Web

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