feat: Support waiting indefinitely for initialization - #36
Draft
kinyoklion wants to merge 2 commits into
Draft
kinyoklion wants to merge 2 commits into
kinyoklion wants to merge 2 commits into
Conversation
Contributor
🤖 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:
|
Contributor
|
@cursor review |
3 tasks
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
This was referenced Sep 16, 2026
Draft
Draft
Contributor
|
@cursor review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
nilwait time now asks the provider to wait for the LaunchDarkly client without a deadline.wait_for_seconds: nilmakesinitwait until the data source becomes valid or fails permanently; the client constructor does not block.initreports a failed initialization unless the client is already ready.initdoes not wait a second time.Found during the weekly OpenFeature provider audit. Updated from the earlier revision of this PR, which overloaded a zero wait time to mean "wait indefinitely".
Requirements
Related issues
None.
Implementation details
The provider keeps the wait time it was constructed with and passes zero to the LaunchDarkly client constructor when it is
nil, so construction never blocks in that case. When the wait time isnil,initsubscribes aDataSourceOutcomeListenerto the data source status provider, then checks whether the client is already initialized or the data source is alreadyOFFbefore blocking on a queue, so an outcome reached between construction and subscription is not missed. The listener is removed once an outcome arrives.VALIDandOFFdecide the outcome;INITIALIZINGandINTERRUPTEDleave the client still trying, so they do not end the wait.Whether initialization succeeded is still decided by
initialized?, and a failure still raises, which the OpenFeature SDK turns into theERRORstate. A failed initialization is not terminal: status changes keep flowing, so a laterVALIDstate reports the provider as ready.Describe alternatives you've considered
Applying a default timeout for
nil:nilis the caller asking for no deadline, and the OpenFeature SDK decides how long to wait for a provider.Polling
initialized?: the data source status provider already reports transitions, so polling would only add latency and wake-ups.Additional context
Testing:
bundle exec rspec(80 examples) andbundle exec rubocopon Ruby 3.4.5. Tests cover an indefinite wait succeeding once the data source becomes valid, an indefinite wait for an outcome arriving afterinitis called, a zero wait time not waiting at all, a positive wait time not waiting a second time, and the outcome listener's per-state behavior.The README's Initialization row describes the
nilbehavior.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