Skip to content

Harden server request cancellation and shutdown - #58

Merged
bisubus merged 179 commits into
masterfrom
fix-server-family
Oct 25, 2026
Merged

bisubus merged 179 commits into
masterfrom
fix-server-family

Conversation

@bisubus

@bisubus bisubus commented Oct 22, 2026

Copy link
Copy Markdown
Member

Summary

  • Request cancel state is recorded on the server it was tracked on, so a request whose socket no longer names a server is dropped from the right registry (HTTP/2 compat).
  • Shutdown drains in-flight responses before closing connections.
  • Handlers that are async generators are rejected with a TypeError instead of hanging the request.
  • Responses canceled after headers were sent are destroyed rather than left open.
  • One abort listener per request forwards cancellation to in-flight tasks. Node 18 warns past ten listeners on one signal, so layers no longer add their own.
  • Request deadline is armed once per request at install time.
  • Hook errors are contained; edge options settle the same way as the rest.
  • Deprecated canceledStatus key kept on fastify; the replacement option name is documented as http1-only.

Changesets

  • server-async-generator-handlers
  • server-cancel-after-head-sent
  • server-fastify-shutdown-close
  • server-hono-error-defaults
  • server-hook-errors-and-edge-options
  • server-http1-only-doc
  • server-late-signal-untracked
  • server-request-deadline
  • server-shutdown-drain-responses
  • server-shutdown-request-counts
  • server-status-option-name

Risks

  1. Behavior change: async generator handlers now reject with a TypeError. Code that wrapped one before gets an error instead of a hang.
  2. Node 24.20 stopped aborting IncomingMessage.signal at body end. Tests branch by Node version; the runtime does not adopt the platform signal, so runtime behavior is unchanged.

Gaps

  • Node 18 has no platform request signal, so the platform spec is skipped there.
  • On Node 24.20 and later, no test pins a live platform signal beyond the version-branched assertion.

CI

https://github.com/cancjs/canc/actions/runs/39766489683 (tip 0cf52d6d, all jobs green)

@bisubus
bisubus merged commit b008798 into master Oct 25, 2026
34 checks passed
@bisubus
bisubus deleted the fix-server-family branch October 25, 2026 15:11
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