[api] Answer nested requests on the sync connection in stack order - #64639
Open
Christopher Plieger (cplieger) wants to merge 1 commit into
Open
Christopher Plieger (cplieger) wants to merge 1 commit into
Christopher Plieger (cplieger) wants to merge 1 commit into
Conversation
Copilot started reviewing on behalf of
Christopher Plieger (cplieger)
October 5, 2026 10:29
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The bidirectional synchronization and panic-recovery behavior warrant final human review despite no concrete blocking findings.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes #64631 by coordinating synchronous IPC exchanges in stack order so overlapping callbacks receive the correct responses.
Changes:
- Tracks in-flight exchanges and waits before starting calls or answering requests.
- Adds regression tests for nested response ordering and response-write panic handling.
| File | Description |
|---|---|
tsc/internal/ipc/conn_sync.go |
Adds stack-based coordination for calls and responses. |
tsc/internal/ipc/conn_sync_test.go |
Tests overlapping nested requests and panic propagation. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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.
While
SyncConn.Callhandles a nested request from a client callback, it releases its lock, so another goroutine's call can start inside the client's pending nested request. Responses are matched by method name, so the nested answer and both callback answers then reach the wrong requests.Impact: a resolver callback that delegates to another resolver, the pattern the API's own test shows, binds most imports to the wrong module once the loader uses more than one thread. Every type and diagnostic the tool reads from that program is then wrong, and no error says so. In the reproduction, 873 of 900 nested answers went to another request.
The connection now keeps a stack of the exchanges in flight. A new call waits while another call is innermost, and a request is answered only once it is innermost again, which is the order a synchronous client handles them in.
A call made from a notification handler while another call is waiting now blocks. No
HandleNotificationin the tree makes a call today.TestSyncConnNestedRequestsAnswerInStackOrderdrives two overlapping callbacks against a fake synchronous client undertesting/synctest. It fails on each of 20 runs without the change. With atscbuilt from this branch, the reproduction in the issue gives 900 right answers of 900.TestSyncConnRunReturnsResponseWritePanickeeps a panic insideWriteResponsereturning an error fromRun, as it does onmain.I met this while building deadset-ts, the TypeScript analyzer of deadset, on the TypeScript 7 API, as part of a small set of defects that work hit, which is why there are a few related reports from me.
An AI coding agent wrote this patch. I have read, built and tested it and will handle the review.
Backlogmilestone (required)mainbranchnpx hereby testnpx hereby lintnpx hereby check:formatFixes #64631