What version of Bun is running?
1.3.11-canary.1+9e93bfa1b
What platform is your computer?
Linux 5.10.0-12-amd64 x86_64 x86_64
What steps can reproduce the bug?
Hi,
I would like to report a behavior in Bun that can be reproduced using the below snippet:
import http from "node:http";
import net from "node:net";
const server = http.createServer((req, res) => {
let closed = false;
res.on("close", () => {
closed = true;
console.log("res close fired");
});
res.write("hello\n");
req.on("error", () => {
server.close(() => {
console.log("server closed, res closed =", closed);
});
});
});
server.listen(3000, () => {
const client = net.createConnection({ port: 3000 }, () => {
client.write(
"GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n"
);
client.on("data", () => {
client.end(); // force abort
});
});
});
What is the expected behavior?
Node.js and Deno both emit ServerResponse "close" when the client disconnects during an active response:
root@KContainer:~/24324# fuser -k 3000/tcp || true && node a.mjs
res close fired
server closed, res closed = true
root@KContainer:~/24324# fuser -k 3000/tcp || true && deno run -A a.mjs
res close fired
server closed, res closed = true
What do you see instead?
The res.on("close") event is not emitted when the client disconnects during an active HTTP response.
root@KContainer:~/24324# fuser -k 3000/tcp || true && bun run a.mjs
server closed, res closed = false
Additional information
No response
What version of Bun is running?
1.3.11-canary.1+9e93bfa1b
What platform is your computer?
Linux 5.10.0-12-amd64 x86_64 x86_64
What steps can reproduce the bug?
Hi,
I would like to report a behavior in Bun that can be reproduced using the below snippet:
What is the expected behavior?
Node.js and Deno both emit ServerResponse "close" when the client disconnects during an active response:
What do you see instead?
The
res.on("close")event is not emitted when the client disconnects during an active HTTP response.Additional information
No response