Skip to content

Add onStdinEnd interrupt policy to stdio RPC and MCP servers - #10415

Merged
tim-smart merged 8 commits into
v4/next-minorfrom
agent/effect-bot/648181b855c3
Nov 9, 2026
Merged

tim-smart merged 8 commits into
v4/next-minorfrom
agent/effect-bot/648181b855c3

Conversation

@effect-bot

@effect-bot effect-bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add opt-in onStdinEnd: "interrupt" to McpServer.layerStdio and the stdio RPC protocol. The default remains "drain", preserving clients that half-close stdin and keep reading responses.

In interrupt mode, stdin EOF ends the protocol's output queue. Already-queued output is flushed, then the existing stdout-completion path stops the server. Existing scope cleanup interrupts active handlers and waits for their finalizers. Output is closed before interruption, so finalizers cannot emit further responses or remote cancellation notifications.

This is a server stop, not a client-disconnect event: onDisconnect is not called. Cleanup belongs in handler finalizers or the layer scope. The RPC disconnect implementation and MCP runtime are unchanged from the PR's original base; no disconnect tracking or cross-transport lifecycle changes are needed.

API migration

The unstable RpcServer.makeProtocolStdio and RpcServer.layerProtocolStdio exports become functions accepting optional { onStdinEnd: "drain" | "interrupt" }. Existing callers must use makeProtocolStdio() / layerProtocolStdio(). Each layer constructor call creates a distinct layer. The effect: minor changeset includes migration instructions.

Validation

All commands run through nix develop -c:

  • pnpm lint-fix, pnpm lint, pnpm check, pnpm jsdocs --check
  • pnpm test --run packages/effect/test/rpc/RpcServer.test.ts packages/effect/test/ai/McpServer/McpServer.test.ts packages/platform/node/test/RpcServer.test.ts: 257 passed.

Coverage includes active-handler and idle EOF shutdown, pending MCP elicitation without remote cancellation, connected cancellation, and existing default-draining behavior. Tests are unchanged in the implementation simplification commit.

Closes #10412
Closes EFF-3436

@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 47a8e45

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
effect Minor
@effect/opentelemetry Minor
@effect/vitest Minor
@effect/ai-anthropic Minor
@effect/ai-cloudflare Minor
@effect/ai-openai-compat Minor
@effect/ai-openai Minor
@effect/ai-openrouter Minor
@effect/ai-typesafe Minor
@effect/atom-react Minor
@effect/atom-solid Minor
@effect/atom-vue Minor
@effect/platform-browser Minor
@effect/platform-bun Minor
@effect/platform-deno Minor
@effect/platform-node-shared Minor
@effect/platform-node Minor
@effect/sql-clickhouse Minor
@effect/sql-d1 Minor
@effect/sql-libsql Minor
@effect/sql-mssql Minor
@effect/sql-mysql2 Minor
@effect/sql-pg Minor
@effect/sql-pglite Minor
@effect/sql-sqlite-bun Minor
@effect/sql-sqlite-do Minor
@effect/sql-sqlite-node Minor
@effect/sql-sqlite-react-native Minor
@effect/sql-sqlite-wasm Minor
@effect/docgen Minor
@effect/doctest Minor
@effect/graphql-generator Minor
@effect/openapi-generator Minor

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

@effect-bot
effect-bot changed the base branch from main to v4/next-minor November 5, 2026 23:43
@effect-janitor effect-janitor Bot added 4.0 and removed 4.0 labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.71 KB 39.71 KB 0.00 KB (0.00%)
basic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
batching.ts 11.29 KB 11.29 KB 0.00 KB (0.00%)
brand.ts 7.00 KB 7.00 KB 0.00 KB (0.00%)
cache.ts 11.83 KB 11.83 KB 0.00 KB (0.00%)
config.ts 23.16 KB 23.16 KB 0.00 KB (0.00%)
differ.ts 22.30 KB 22.30 KB 0.00 KB (0.00%)
http-client.ts 27.43 KB 27.43 KB 0.00 KB (0.00%)
http-router.ts 37.30 KB 37.30 KB 0.00 KB (0.00%)
logger.ts 12.28 KB 12.28 KB 0.00 KB (0.00%)
metric.ts 9.74 KB 9.74 KB 0.00 KB (0.00%)
optic.ts 7.21 KB 7.21 KB 0.00 KB (0.00%)
pubsub.ts 16.34 KB 16.34 KB 0.00 KB (0.00%)
queue.ts 13.20 KB 13.20 KB 0.00 KB (0.00%)
schedule.ts 12.07 KB 12.07 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.33 KB 14.33 KB 0.00 KB (0.00%)
schema-binary.ts 42.48 KB 42.48 KB 0.00 KB (0.00%)
schema-class.ts 22.05 KB 22.05 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.00 KB 30.00 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.32 KB 28.32 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.64 KB 15.64 KB 0.00 KB (0.00%)
schema-string.ts 12.53 KB 12.53 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.51 KB 16.51 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 39.26 KB 39.26 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 26.46 KB 26.46 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.21 KB 21.21 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.38 KB 21.38 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.47 KB 21.47 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.47 KB 26.47 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.54 KB 21.54 KB 0.00 KB (0.00%)
schema.ts 21.14 KB 21.14 KB 0.00 KB (0.00%)
stm.ts 14.50 KB 14.50 KB 0.00 KB (0.00%)
stream.ts 10.66 KB 10.66 KB 0.00 KB (0.00%)
supervisor.ts 11.61 KB 11.61 KB 0.00 KB (0.00%)

- disconnect: drop the empty-fibers early return, Fiber.awaitAll handles it
- handleDisconnect: use the lazy andThen form instead of an explicit suspend
- layerProtocolStdio: remove the generic layer-memoization gotcha now that
  it is an ordinary layer constructor
@tim-smart
tim-smart merged commit 617a28d into v4/next-minor Nov 9, 2026
14 checks passed
@tim-smart
tim-smart deleted the agent/effect-bot/648181b855c3 branch November 9, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

McpServer.layerStdio: native EOF cancellation policy for active tool handlers

2 participants