feat: Add a start wait timeout for initialization - #61
Open
kinyoklion wants to merge 4 commits into
Open
Conversation
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
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 |
kinyoklion
commented
Aug 26, 2026
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
kinyoklion
marked this pull request as ready for review
August 27, 2026 22:00
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.
initializeblocked onCompletableFuture.get()with no timeout, so a provider whose data source never became valid and never permanently failed would wait forever.Closes #58.
Provider(String sdkKey, LDConfig config, Duration startWait), which configures both the SDK's start wait and the provider's initialization timeoutERRORandinitializethrows, distinct from the existing initialization-failure pathLDConfig.startWaituntouched and wait indefinitely, so a caller who configuredstartWaitthemselves is not overriddenLDConfig.startWaitrather than inventing a cross-provider nameImplementation details
Requirements
Related issues
#58
Describe the solution you've provided
LDClientonly exposes one- and two-argument constructors andLDConfighas no start-wait getter, so the three-argument constructor applies the duration throughLDConfig.Builder.startWait(...)and keeps its own copy for the timedget. That also means the two-argument constructor cannot discover the caller's configured start wait to reuse it as a provider timeout, which is why it stays indefinite rather than silently adopting a default.Describe alternatives you've considered
Making the existing constructors default to the SDK's five second start wait would have given every caller a timeout without an API change, but it overrides a
startWaitthe caller set on their ownLDConfig— which the README tells them to do — so it was rejected as a silent behavior change.Additional context
Testing:
./gradlew test checkstyleMain— all tests and checkstyle pass. New lifecycle tests cover a positive start wait timing out against a data source that never becomes ready, a zero start wait not timing out, and the two-argument constructor preserving a configured start wait.Link to Devin session: https://app.devin.ai/sessions/38a6eaf69fcf41109e136a1d0fe5e899
Requested by: @kinyoklion
Note
Overview
Fixes indefinite blocking during
initializewhen a data source never becomes valid and never permanently fails.Adds
Provider(String, LDConfig, Duration), which sets both the LaunchDarkly SDKstartWaitand the provider’s wait on the initialization future. A zero duration keeps the prior behavior (no provider timeout). Existing one- and two-argument constructors are documented to wait indefinitely and no longer override a caller’sLDConfig.startWaitfor provider timeout purposes.On timeout, the provider moves to
ERRORandinitializethrows aRuntimeException(“Wait for initialization timed out.”), separate from the existing permanent-failure path. README initialization docs are updated accordingly; lifecycle tests cover positive timeout, zero wait, and two-arg constructor preserving configstartWait.Reviewed by Cursor Bugbot for commit b8e23e1. Bugbot is set up for automated code reviews on this repo. Configure here.