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 @@ -1045,6 +1045,21 @@ ensure the response is a properly formatted HTTP response message.
10451045  correctly;
10461046*  ` rawPacket ` : the raw packet of current request.
10471047
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+ 
10481063### Event: ` 'close' `   
10491064<!--  YAML
10501065added: v0.1.4 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments