We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
nodejs
Learn more about funding links in repositories.
Report abuse
1 parent 30c9cb5 commit 318fcf8Copy full SHA for 318fcf8
doc/api/http.md
@@ -1003,6 +1003,21 @@ ensure the response is a properly formatted HTTP response message.
1003
correctly;
1004
* `rawPacket`: the raw packet of current request.
1005
1006
+In some cases, the client has already received the response and/or the socket
1007
+has already been destroyed, like in case of `ECONNRESET` errors. Before
1008
+trying to send data to the socket, it is better to check that it is still
1009
+writable.
1010
+
1011
+```js
1012
+server.on('clientError', (err, socket) => {
1013
+ if (err.code === 'ECONNRESET' || !socket.writable) {
1014
+ return;
1015
+ }
1016
1017
+ socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
1018
+});
1019
+```
1020
1021
### Event: `'close'`
1022
<!-- YAML
1023
added: v0.1.4
0 commit comments