Repository navigation
Conversation
🦋 Changeset detectedLatest commit: ea81ac2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
karaaslanz
left a comment
There was a problem hiding this comment.
Exact-source review of draft HEAD fdd1ffb9baef3d93c996224d164d5b2ebaf4db7f. Found a reproducible post-close write race introduced by async outbound interception.
Location: packages/server/src/server/serveStdio.ts, StdioConnectionChannel.send (approx. lines 184?197). It checks this._closed before await this._outboundIntercept?.(message), but not again afterwards. modernOutboundIntercept is now async, introducing an await boundary even for ordinary responses where interception returns undefined. If the channel is closed/discarded during the await, the continuation still forwards the message to the shared wire after close() finished.
Exact-source reproduction: fetched serveStdio.ts from the PR head (blob 4f6d5fc7928b93269c149d25691428022e82c153), transformed the actual StdioConnectionChannel class with Node 24 TypeScript-strip, instantiated it using a deferred async interceptor and a counting fake wire. Sequence:
- Start
channel.send({jsonrpc:'2.0', id:7, result:{ok:true}}); interceptor awaits. await channel.close().- Resolve the interceptor with
undefined; then await the pending send. - Observed
WIRE_WRITES_AFTER_CLOSE = 1.
No repo files changed. This is a deterministic exact-source isolated test, not a full stdio integration suite.
Narrow fix and regression gate: check this._closed again after awaiting interception, before this._wire.send. Add a deferred-interceptor test that closes the channel between the two steps and verifies zero writes to the shared wire. This prevents discarded connection instances from emitting late messages. I did not review the broader admission-completion design end to end.
|
The post-close stdio write race was fixed in
The PR description contains the current validation results, completion contract, and review status. |
Retain processing promises through OpenTelemetry scopes so admission completion still follows owned work and cleanup. Cover ended spans, cancellation, close, asynchronous validation and immediate request-ID reuse. Clarify the completion contract in the documentation and changeset.
|
The final fixes are in The proposal adds a local completion signal for reusable transport admission. Completion follows SDK-owned processing, response writes, cache invalidation and cleanup; cancellation or connection closure alone does not release unfinished work. The metadata is never serialized. The PR description records the final scope, exact validation results and local environment limitations. This is ready for maintainer review and ownership. Maintainer edits are enabled. Maintainers are welcome to adjust the API or implementation, split or cherry-pick the changes, and merge through the repository's normal review process. No further sign-off from me is needed. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2020035c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c71cd8cbf7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Could a maintainer remove my individual review request for karaaslanz? I’d like the TypeScript SDK code-owner team to keep its review request. I’d also appreciate feedback on the proposed completion contract in #3020. Each inbound message has its own local completion callback. For an |
Motivation
A transport that limits concurrent requests needs to know when it can reuse a slot. A cancelled request can still have a running handler, and a response can reach
send()before the SDK has finished the write and removed the request controller. See #3020.Proposed API
A transport can attach an optional
onMessageProcessed(): voidcallback to a message’s localMessageExtraInfo. The SDK calls it once after the work it owns for that message settles. The callback stays off the wire. Applications remain responsible for work they start outside a handler’s returned promise.input_requiredresponse, the SDK releases the current message’s credit after the local input handler hands off the retry, so a single-credit transport can admit the next response.The stdio entry exports
supportsInboundMessageCompletionfor adapters that require this guarantee. The design question for review is whether this per-message boundary belongs in the transport API.Verification
Regression tests cover cancellation with a running handler, a single-credit retry, failed listen acknowledgements, and concurrent stdio writes. On
ea81ac24, 3,751 tests passed across core-internal, client, and server. One optional soak test was skipped. The SDK build, typecheck, lint, documentation build, and all 14 GitHub checks passed.