Skip to content

Cancel idle RPC readable streams when their consumers stop - #8

Closed
mmkal wants to merge 2 commits into
mainfrom
codex/idle-readable-cancellation
Closed

mmkal wants to merge 2 commits into
mainfrom
codex/idle-readable-cancellation

Conversation

@mmkal

@mmkal mmkal commented Sep 9, 2026

Copy link
Copy Markdown

Cancelling a remote readable stream now cancels its producer while it is idle. Previously the producer only learned about cancellation when it sent another chunk, leaving SSE producers running indefinitely.

Use the existing rejection message to notify the sender, and pump with an owned reader so cancellation reaches the source. In workerd 1.20260205.0, an idle pipeTo did not cancel its source after either destination failure or an AbortSignal. The explicit pump preserves write backpressure, forwards source errors, and releases locks without awaiting user cancellation callbacks. Disposed imports also release their failure callbacks instead of retaining them until the session closes.

Validation: 612 Node/workerd tests, build and type tests passed. Callback-returned consumed/locked Response cases pass on both runtimes; existing rejection behavior is preserved. The idle-cancellation and session-disconnect regressions failed before their fixes and passes with no leaked RPC imports/exports.

Review focus: stream cancellation and cleanup in src/rpc.ts, followed by writer failure signaling in src/streams.ts. No protocol message types added. This PR requests a pkg.pr.new preview for downstream integration testing; no npm release.

Codex session: 01a07b03-100a-7803-ba3f-caed48046317

@pkg-pr-new

pkg-pr-new Bot commented Sep 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/iterate/capnweb/@iterate-com/capnweb@8

commit: 677465a

@mmkal

mmkal commented Sep 9, 2026

Copy link
Copy Markdown
Author

I'm so sorry! An over-eager clanker just created this for me, I can't vouch for it. I will scold/update my AGENTS.md.

@mmkal mmkal closed this Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant