Environment
[email protected]
node@lts/jod
Reproduction
const server = serve({
port: 3000,
fetch(request) {
request.signal.addEventListener("abort", () => {
console.log("ABORT FIRED"); // This fires on EVERY request
});
return new Response("ok");
},
});
Describe the bug
Cause
In src/adapters/_node/request.ts, the _abortController getter listens to req.once("end", abort). The end event on IncomingMessage fires when the request body is done being read, not when the client disconnects.
Impact
- OpenTelemetry traces show every request as "aborted"
- Any code checking
request.signal.aborted sees incorrect state
- Streaming responses don't behave correctly
Expected behavior
Abort signal should only fire when:
- Client disconnects before response completes
- Request errors
This matches Bun's behavior and @hono/node-server's implementation.
Solution
Listen to res.on("close") and check res.writableEnded instead. PR incoming.
Additional context
No response
Logs