Repository navigation
Settle start() with the outcome of an initialization retry - #1924
Merged
Dirk Bäumer (dbaeumer) merged 4 commits intoOct 30, 2026
Merged
Conversation
Contributor
Author
|
Some history on why
So |
Dirk Bäumer (dbaeumer)
previously approved these changes
Oct 27, 2026
Member
|
Trivikram Kamat (@trivikr) see the Copilot review comments. Especially the first one seems valid to me. |
When initialize failed and the client retried, either because initializationFailedHandler returned true or because the user picked Retry for an InitializeError with retry: true, doInitialize started the retry in the background and rethrew. start() rejected and the client moved to StartFailed. A successful retry then switched the client to Running while start() had already rejected, and later start() calls kept returning that rejected promise. A failed retry rejected a promise nobody observed, so it surfaced as an unhandled rejection. Return the retry from doInitialize, and await the Retry choice, so start() resolves or rejects once with the result of the last attempt. Stop the client in one place after a failed initialization is not retried. For a retryable InitializeError without a handler, start() now stays pending until the user answers the Retry message instead of rejecting while it is shown. Add integration tests for a successful and a failed retry through initializationFailedHandler and through the Retry message.
start() waits for the user to answer the Retry message of a retryable InitializeError. If the server exited while the message was shown, the close handling moved the client to StartFailed, or restarted it, but the pending start() calls stayed unsettled until the user answered a message for a connection that was already gone. Answering it then acted on the stale connection: Retry sent initialize on the disposed connection, and dismissing stopped the client, which after a restart was the new one. Race the Retry message against the connection closing, and reject the start without stopping the client when the connection closes first, ignoring a later answer. Only mark the client as StartFailed when the failing start is still the current one, so a late rejection doesn't override a restart. Add an integration test with a server that exits while the Retry message is open.
The tests for a failed retry used a server that refused every initialization with the same error, so they couldn't show that start() rejects with the error of the last attempt, and no test covered a failed retry chosen from the Retry message. Add a server that asks for a retry and then fails it with a distinct error. Use it for the initializationFailedHandler retry test, and add a test that picks Retry from the message and checks that start() rejects with the final error, the client is stopped once, and no rejection is unhandled.
Trivikram Kamat (trivikr)
force-pushed
the
client-settle-start
branch
from
October 27, 2026 16:25
a46789f to
c0d5d02
Compare
Contributor
Author
Dirk Bäumer (@dbaeumer) I incorporated suggestions from both comments, and pushed commits. |
Dirk Bäumer (dbaeumer)
approved these changes
Oct 29, 2026
Martin Aeschlimann (aeschli)
approved these changes
Oct 29, 2026
Vritant Bhardwaj (vritant24)
approved these changes
Oct 29, 2026
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.

When initialize failed and the client retried, either because initializationFailedHandler returned true or because the user picked Retry for an InitializeError with retry: true, doInitialize started the retry in the background and rethrew. start() rejected and the client moved to StartFailed. A successful retry then switched the client to Running while start() had already rejected, and later start() calls kept returning that rejected promise. A failed retry rejected a promise nobody observed, so it surfaced as an unhandled rejection.
Return the retry from doInitialize, and await the Retry choice, so start() resolves or rejects once with the result of the last attempt. Stop the client in one place after a failed initialization is not retried. For a retryable InitializeError without a handler, start() now stays pending until the user answers the Retry message instead of rejecting while it is shown. Add integration tests for a successful and a failed retry through initializationFailedHandler and through the Retry message.