fix(mcp): clear initialize response suppression after first match#625
Open
chiehwangs wants to merge 1 commit into
Open
fix(mcp): clear initialize response suppression after first match#625chiehwangs wants to merge 1 commit into
chiehwangs wants to merge 1 commit into
Conversation
## Description The local-handshake proxy immediately returns an initialize response while the shared daemon connects in the background. It forwards the initialize request to the daemon and suppresses the daemon's duplicate response. However, a later JSON-RPC request can reuse the initialize request ID after the handshake completes. In that case, the proxy incorrectly drops the later response. ## Root Cause The proxy stores the initialize request ID in `clientInitId` to identify the daemon's duplicate initialize response. After filtering the matching response, it leaves `clientInitId` unchanged. The suppression logic therefore continues matching every later daemon response with the same request ID. ## Fix Clear `clientInitId` immediately after suppressing the first matching daemon response. Add a real daemon regression test that initializes with ID 1, reuses ID 1 for a subsequent ping request, and verifies that the later response is relayed to the client.
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.
Description
The local-handshake proxy immediately returns an initialize response while the shared daemon connects in the background. It forwards the initialize request to the daemon and suppresses the daemon's duplicate response. However, a later JSON-RPC request can reuse the initialize request ID after the handshake completes. In that case, the proxy incorrectly drops the later response.
Root Cause
The proxy stores the initialize request ID in
clientInitIdto identify the daemon's duplicate initialize response. After filtering the matching response, it leavesclientInitIdunchanged. The suppression logic therefore continues matching every later daemon response with the same request ID.Fix
Clear
clientInitIdimmediately after suppressing the first matching daemon response. Add a real daemon regression test that initializes with ID 1, reuses ID 1 for a subsequent ping request, and verifies that the later response is relayed to the client.