File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -762,7 +762,10 @@ const requestHeaderFieldsTooLargeResponse = Buffer.from(
762762function socketOnError ( e ) {
763763 // Ignore further errors
764764 this . removeListener ( 'error' , socketOnError ) ;
765- this . on ( 'error' , noop ) ;
765+
766+ if ( ! this . listenerCount ( 'error' ) ) {
767+ this . on ( 'error' , noop ) ;
768+ }
766769
767770 if ( ! this . server . emit ( 'clientError' , e , this ) ) {
768771 if ( this . writable && this . bytesWritten === 0 ) {
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common' ) ;
4+ const http = require ( 'http' ) ;
5+ const net = require ( 'net' ) ;
6+
7+ const server = http . createServer ( ( req , res ) => {
8+ res . writeHead ( 200 ) ;
9+ res . end ( 'response' ) ;
10+ } ) ;
11+
12+ server . on ( 'clientError' , common . mustCallAtLeast ( ( ) => { } , 1 ) ) ;
13+ process . on ( 'warning' , common . mustNotCall ( ) ) ;
14+
15+ server . listen ( 0 , ( ) => {
16+ const client = net . createConnection ( { port : server . address ( ) . port } ) ;
17+
18+ client . on ( 'connect' , ( ) => {
19+ for ( let i = 0 ; i < 20 ; i ++ ) {
20+ setTimeout ( ( ) => {
21+ client . write ( '*\r\n' ) ;
22+ } , common . platformTimeout ( i * 10 ) ) ;
23+ }
24+
25+ setTimeout ( ( ) => {
26+ client . end ( ) ;
27+ server . close ( ) ;
28+ } , common . platformTimeout ( 1000 ) ) ;
29+ } ) ;
30+ } ) ;
You can’t perform that action at this time.
0 commit comments