Skip to content

Guard request half-close abort on readableEnded - #771

Closed
nstandif wants to merge 6 commits into
restatedev:mainfrom
nstandif:worktree-fix-abort-request-response
Closed

Guard request half-close abort on readableEnded#771
nstandif wants to merge 6 commits into
restatedev:mainfrom
nstandif:worktree-fix-abort-request-response

Conversation

@nstandif

@nstandif nstandif commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes #745.

Depends on #774 (unrelated e2e test issue this change exposes; CI won't be green here until that merges).

In REQUEST_RESPONSE mode, the runtime half-closes the request after the journal is delivered and keeps the response open for the reply. The request's "close" event was aborting the invocation unconditionally, killing any handler suspended on a call or promise. Surfaced as [500] Connection closed plus a retry loop.

complete can't distinguish a clean half-close from a mid-stream RST on Node 24 (both read true). readableEnded can: it's only true after the stream actually saw "end".

Fix: gate the abort on !request.readableEnded, extracted into abortSignalForRequest.

Added test/node_endpoint.test.ts against a real node:stream Readable. Confirmed the test fails without the guard before adding it. Suite and typecheck pass.

No public API change, so no changeset. Flag if you want a release note anyway.

The runtime closes the request body once the journal is fully
streamed in REQUEST_RESPONSE mode while the response stays open
awaiting output, which fires "close" on a still-suspended handler
and killed it with a spurious "(500) Connection closed". Only abort
when "close" fires before the request has actually ended.
@nstandif nstandif changed the title Don't abort suspended handlers on REQUEST_RESPONSE half-close Guard request half-close abort on readableEnded Jul 29, 2026
@nstandif
nstandif marked this pull request as draft July 29, 2026 02:43
@nstandif
nstandif marked this pull request as ready for review July 30, 2026 05:39
nstandif added 2 commits July 29, 2026 22:41
Both IncomingMessage and Http2ServerRequest already extend it directly,
so it's the real common interface, not something to reinvent.
@nstandif
nstandif force-pushed the worktree-fix-abort-request-response branch from c55f5bd to c4a3870 Compare July 30, 2026 06:05
@nstandif
nstandif force-pushed the worktree-fix-abort-request-response branch 2 times, most recently from b071c8b to 00a2cb6 Compare July 30, 2026 06:33
@nikrooz

nikrooz commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

This should have been fixed by #787 and been released in 1.16.9. Please reopen the issue if still not resolved

@nikrooz nikrooz closed this Aug 24, 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.

request/response: SDK aborts the invocation on request half-close, killing suspended handlers

2 participants