File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,14 @@ let connections = 0;
3030
3131server . on ( 'request' , function ( req , res ) {
3232 req . socket . setTimeout ( 1000 ) ;
33- req . socket . on ( 'timeout' , function ( ) {
33+ const ontimeout = function ( ) {
3434 throw new Error ( 'Unexpected timeout' ) ;
35- } ) ;
35+ } ;
36+ req . socket . on ( 'timeout' , ontimeout ) ;
3637 req . on ( 'end' , function ( ) {
3738 connections -- ;
3839 res . writeHead ( 200 ) ;
40+ req . socket . off ( 'timeout' , ontimeout ) ;
3941 res . end ( 'done\n' ) ;
4042 if ( connections === 0 ) {
4143 server . close ( ) ;
@@ -57,7 +59,8 @@ server.listen(0, function() {
5759
5860 function ping ( ) {
5961 const nextPing = ( Math . random ( ) * 900 ) . toFixed ( ) ;
60- if ( nextPing > 600 ) {
62+ // Do not set too big to prevent req.socket from emitting timeout
63+ if ( nextPing > 300 ) {
6164 request . end ( ) ;
6265 return ;
6366 }
You can’t perform that action at this time.
0 commit comments