Skip to content

feat: Support zero and indefinite initialization waiting - #2024

Draft
kinyoklion wants to merge 2 commits into
mainfrom
devin/1789570917-of-start-wait
Draft

kinyoklion wants to merge 2 commits into
mainfrom
devin/1789570917-of-start-wait

Conversation

@kinyoklion

Copy link
Copy Markdown
Member

Gives the OpenFeature providers the initialization waiting values the OpenFeature provider spec (OFP) requires, which the numeric-only initTimeoutSeconds could not express.

  • initTimeoutSeconds: null waits indefinitely for the LaunchDarkly client
  • initTimeoutSeconds: 0 waits nowhere and fails initialization unless the client is already ready, so readiness is observed through provider events
  • A positive timeout behaves as before, and the default is still 10 seconds
  • Node provider README feature matrix row updated for the new values
Implementation details

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

OFP requirement 4.3.4 requires a value distinct from any duration to request waiting indefinitely, and 4.3.6 requires a zero wait to wait nowhere and fail initialization. Sibling changes for the same requirement: launchdarkly/openfeature-java-server#66, launchdarkly/openfeature-python-server#64, launchdarkly/openfeature-dotnet-server#71, launchdarkly/openfeature-ruby-server#36.

Describe the solution you've provided

BaseOpenFeatureProvider takes number | null and no longer coalesces zero into the default, since ?? only replaces undefined. waitForInitialization treats a falsy timeout as no timeout, so zero cannot be passed through: initialization races the pending initialization promise against an immediately rejected one, which succeeds only when the client is already ready.

The Cloudflare provider is unaffected because it evaluates from a KV namespace and has no data source to wait for.

Describe alternatives you've considered

Adding initialized() to the client contract would let the zero case be checked directly, but that is a breaking change to a published interface for behavior the existing promise already expresses.

Additional context

Verified with yarn workspace @launchdarkly/openfeature-js-server-common test (82 tests), yarn workspace @launchdarkly/openfeature-node-server test (29 tests), and lint and format checks for both packages.

Link to Devin session: https://app.devin.ai/sessions/1fd3fcbfe79f482e8b58be29e8df2ffb
Open in Devin Desktop: https://app.devin.ai/desktop/session/1fd3fcbfe79f482e8b58be29e8df2ffb?variant=devin
Requested by: @kinyoklion

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration

Copy link
Copy Markdown
Contributor

@cursor review

@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: 32597 bytes
Compressed size limit: 34000
Uncompressed size: 116806 bytes

@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: 26983 bytes
Compressed size limit: 29000
Uncompressed size: 131377 bytes

Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
@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: 25421 bytes
Compressed size limit: 44000
Uncompressed size: 165321 bytes

This branch has not been deployed

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

Labels

devin-pr PRs created by Devin AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant