feat: Support zero and indefinite initialization waiting - #2024
kinyoklion wants to merge 2 commits into
Conversation
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
@cursor review |
|
@launchdarkly/js-client-sdk size report |
|
@launchdarkly/js-sdk-common size report |
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
|
@launchdarkly/js-client-sdk-common size report |
Gives the OpenFeature providers the initialization waiting values the OpenFeature provider spec (OFP) requires, which the numeric-only
initTimeoutSecondscould not express.initTimeoutSeconds: nullwaits indefinitely for the LaunchDarkly clientinitTimeoutSeconds: 0waits nowhere and fails initialization unless the client is already ready, so readiness is observed through provider eventsImplementation details
Requirements
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
BaseOpenFeatureProvidertakesnumber | nulland no longer coalesces zero into the default, since??only replacesundefined.waitForInitializationtreats 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