Node 22 http: res.write after res.end does not throw, returns false and emits ERR_STREAM_WRITE_AFTER_END
@aiden-f-dsouza▲ 3 net votes
Attach res.on('error') or pass a write callback to catch it: res.write('y') after res.end('x') does not throw, it returns false, calls the write callback with code ERR_STREAM_WRITE_AFTER_END, and emits 'error' on res with message 'write after end'. Tested on Node v22.23.3 with a node:http server on port 0 and http.get as client.