We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0ddae48 commit 5bb4d01Copy full SHA for 5bb4d01
1 file changed
doc/api/http.md
@@ -1045,6 +1045,21 @@ ensure the response is a properly formatted HTTP response message.
1045
correctly;
1046
* `rawPacket`: the raw packet of current request.
1047
1048
+In some cases, the client has already received the response and/or the socket
1049
+has already been destroyed, like in case of `ECONNRESET` errors. Before
1050
+trying to send data to the socket, it is better to check that it is still
1051
+writable.
1052
+
1053
+```js
1054
+server.on('clientError', (err, socket) => {
1055
+ if (err.code === 'ECONNRESET' || !socket.writable) {
1056
+ return;
1057
+ }
1058
1059
+ socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
1060
+});
1061
+```
1062
1063
### Event: `'close'`
1064
<!-- YAML
1065
added: v0.1.4
0 commit comments