Repository navigation
fix!: Use None rather than zero for indefinite initialization waiting - #64
kinyoklion wants to merge 5 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 |
|
Devin check this against the latest version of the spec. |
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6385f3e. Configure here.
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Rechecked against the latest OFP spec (
|
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com> # Conflicts: # ld_openfeature/provider.py # tests/test_provider.py
Gives the OpenFeature providers the initialization waiting values the OpenFeature provider spec (OFP) requires, which the numeric-only `initTimeoutSeconds` could not express. - `initTimeoutSeconds: 'forever'` 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 <details> <summary>Implementation details</summary> **Requirements** - [x] I have added test coverage for new or changed functionality - [x] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [x] 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** `BaseProviderConfig.initTimeoutSeconds` and the Node provider's constructor parameter are now `number | 'forever'`, and zero is no longer coalesced 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** `number | null` was used initially for the indefinite case; `'forever'` reads better at the call site and matches the repository's preference for string unions. 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, format and build checks for both packages. </details> 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 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > Extends **`initTimeoutSeconds`** on the shared **`BaseOpenFeatureProvider`** and the Node **`LaunchDarklyProvider`** to **`number | 'forever'`**, aligning initialization with the OpenFeature provider spec. > > **`'forever'`** calls **`waitForInitialization()`** with no timeout. **`0`** no longer falls through to the 10-second default (only **`undefined`** does); initialization races the client’s init promise against an immediate failure so it succeeds only when the client is already ready, otherwise it throws a clear error. Positive timeouts behave as before (default **10** seconds). > > The Node provider README initialization row documents the new values, and unit tests cover indefinite wait, zero-timeout failure, and zero-timeout success when already ready. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 87e9a23. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… row (#68) ## Summary LaunchDarkly Python SDK 9.18.0 made a rejected SDK key retryable rather than permanently stopping the data source. The README says `start_wait=0` waits "until the data source becomes valid or permanently fails", but a rejected key now never permanently fails. With zero, `initialize` therefore never completes while the key is rejected. - Initialization row: now⚠️ , notes the SDK 9.18.0 behavior, and marks the provider gap (zero should mean "do not wait", per OFP 4.3.6), tracked by [#64](#64). - The `start_wait` paragraph gets the same note. <details> <summary>Details</summary> I checked this locally with `launchdarkly-server-sdk` 9.18.1 and an invalid key. The data source stayed `INITIALIZING`, and `last_error` reported `ERROR_RESPONSE 401` while it retried. It never reported `OFF`. The provider allows `launchdarkly-server-sdk >=9.17.0,<10`, so new installs get the retry behavior. #64 also edits these lines. Whichever merges second will need a small README conflict fix. Found in the weekly OpenFeature provider audit. Docs-only change. </details> Link to Devin session: https://app.devin.ai/sessions/c8bc4e80339b473882c2dddffe981edf Open in Devin Desktop: https://app.devin.ai/desktop/session/c8bc4e80339b473882c2dddffe981edf?variant=devin Requested by: @kinyoklion [SDK-3286](https://launchdarkly.atlassian.net/browse/SDK-3286) [SDK-3286]: https://launchdarkly.atlassian.net/browse/SDK-3286?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > Updates **README** to reflect LaunchDarkly Python SDK **9.18.0+** behavior: a rejected SDK key is **retried** instead of permanently failing the data source. > > The **Initialization** feature matrix row is downgraded from ✅ to **⚠️ **, with notes that `start_wait=0` can wait indefinitely on a bad key and that the provider still has a gap (zero should mean “do not wait” per OpenFeature), linked to **#64**. The **`start_wait`** getting-started paragraph adds the same SDK 9.18.0 caveat so it matches the matrix. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4b2f0cc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com> # Conflicts: # README.md

Aligns
start_waitwith the OpenFeature provider spec (OFP), which requires a distinct non-duration value to request indefinite initialization waiting.start_wait=Nonenow requests an indefinite wait: the constructor does not block andinitializewaits until the data source becomes valid or fails permanently.start_wait=0no longer waits indefinitely; it waits nowhere, soinitializereports a failed initialization unless the client is already ready, and readiness is observed through provider events.initializereturns immediately with whatever the outcome is.0meaning "wait forever".Requirements
Related issues
None.
Implementation details
OFP requires that a positive start wait bound total construction plus initialization, that zero wait nowhere, and that indefinite waiting avoid construction-time blocking and instead wait during
initialize. Previously zero was overloaded to mean indefinite, leaving no way to express "no waiting at all".Noneis now passed toLDClientas a zero construction wait, with the waiting performed ininitializeagainst the data source status listener.Testing:
make test(88 tests) andmake lint(mypy) pass. New tests cover the zero and indefinite cases, including that the constructor does not block whenNoneis given.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
SDK-3285
Note
Overview
Breaking:
start_waitnow matches the OpenFeature provider spec—0means no waiting anywhere; indefinite waiting usesNoneinstead of0.With
start_wait=0, the constructor andinitializedo not block on the data source;initializeraises unless the LD client is already ready, and later readiness is surfaced viaPROVIDER_READY(and related) events. Withstart_wait=None, construction still passes0toLDClient, butinitializewaits without a deadline until the data source is valid or permanently fails. Positivestart_waitbehavior is unchanged.Provider event emission is reworked: status is tracked with
ProviderStatus, listeners are registered before the init wait, and the status change that completes OpenFeature initialization is not duplicated as a provider event—subsequent transitions (including recovery after a failed init withstart_wait=0) are emitted. README and tests cover the new semantics, includingDelayedReadyDataSourceand post-failure ready events.Reviewed by Cursor Bugbot for commit f242a59. Bugbot is set up for automated code reviews on this repo. Configure here.