File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1003,6 +1003,21 @@ ensure the response is a properly formatted HTTP response message.
1003
1003
correctly;
1004
1004
* ` rawPacket ` : the raw packet of current request.
1005
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
+
1006
1021
### Event: ` 'close' `
1007
1022
<!-- YAML
1008
1023
added: v0.1.4
You can’t perform that action at this time.
0 commit comments