security: a rejecting static resolver becomes an unhandled rejection on Node #108

Closed
opened 2026-09-25 14:02:13 +00:00 by chrnx · 1 comment
Owner

Kept internal under SECURITY.md until the other four are fixed, since it can also take the process down.

The Node request listener (src/http/server.ts:99) is async, and a failure from dispatch, for example a custom opts.static resolver that rejects (src/http/core.ts:166), is not caught. Node's default for an unhandled rejection is to exit.

Fix: catch at the listener boundary, log the error, and answer 500 when headers have not been sent. Test: a resolver that throws gives a 500, and the server keeps serving.

Kept internal under SECURITY.md until the other four are fixed, since it can also take the process down. The Node request listener (src/http/server.ts:99) is `async`, and a failure from dispatch, for example a custom `opts.static` resolver that rejects (src/http/core.ts:166), is not caught. Node's default for an unhandled rejection is to exit. **Fix:** catch at the listener boundary, log the error, and answer 500 when headers have not been sent. **Test:** a resolver that throws gives a 500, and the server keeps serving.
chrnx added the bugsecurity labels 2026-09-25 16:06:53 +00:00
Author
Owner

Fixed in 26.11.0-rc.1 (8b67b1a, 1069c72). From the changelog:

  • A request that fails past the error renderer no longer takes the Node process down (#108). The Node request listener was an async function, and http.createServer ignores the promise it returns, so anything that rejected outside the region where errors convert to a response — a custom static resolver, a handler header value Node refuses to write, a stream that fails before its first frame — became an unhandled rejection, which Node's default mode turns into an exit. The listener now catches it. While the response is still writable the client gets a fixed 500 with connection: close, written without calling onError again; once output has started the socket is destroyed instead. Either way the failure is logged through logger.error. No request:end is emitted for these requests. Deno, Bun and the edge were not affected: they receive app.fetch's promise, and the runtime answers a rejection with a 500 itself.
Fixed in **26.11.0-rc.1** (`8b67b1a`, `1069c72`). From the changelog: - **A request that fails past the error renderer no longer takes the Node process down** (#108). The Node request listener was an `async` function, and `http.createServer` ignores the promise it returns, so anything that rejected outside the region where errors convert to a response — a custom static resolver, a handler header value Node refuses to write, a stream that fails before its first frame — became an unhandled rejection, which Node's default mode turns into an exit. The listener now catches it. While the response is still writable the client gets a fixed 500 with `connection: close`, written without calling `onError` again; once output has started the socket is destroyed instead. Either way the failure is logged through `logger.error`. No `request:end` is emitted for these requests. Deno, Bun and the edge were not affected: they receive `app.fetch`'s promise, and the runtime answers a rejection with a 500 itself.
chrnx closed this issue 2026-11-18 01:04:02 +00:00
Sign in to join this conversation.