File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
Expand file tree Collapse file tree 2 files changed +35
-1
lines changed 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 assert = require ( 'assert' ) ;
5+ const http = require ( 'http' ) ;
6+ const net = require ( 'net' ) ;
7+
8+ const server = http . createServer ( ( req , res ) => {
9+ res . writeHead ( 200 ) ;
10+ res . end ( 'response' ) ;
11+ } ) ;
12+
13+ server . on ( 'clientError' , common . mustCallAtLeast ( ( ) => { } , 1 ) ) ;
14+ process . on ( 'warning' , common . mustNotCall ( ) ) ;
15+
16+ server . listen ( 0 , ( ) => {
17+ const client = net . createConnection ( { port : server . address ( ) . port } ) ;
18+
19+ client . on ( 'connect' , ( ) => {
20+ for ( let i = 0 ; i < 20 ; i ++ ) {
21+ setTimeout ( ( ) => {
22+ client . write ( '*\r\n' ) ;
23+ } , common . platformTimeout ( i * 10 ) )
24+ }
25+
26+ setTimeout ( ( ) => {
27+ client . end ( ) ;
28+ server . close ( ) ;
29+ } , common . platformTimeout ( 1000 ) ) ;
30+ } )
31+ } ) ;
You can’t perform that action at this time.
0 commit comments