File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 1010- Fixes bug where the functions emulator would attempt to call to prod for 'demo-' projects (#5170 )
1111- Address issues starting the Firebase Hosting emulator with some versions of Next.js (#5781 )
1212- Fix regex page matcher for Next.js middlewares version 1 (#5496 )
13+ - Fixes bug where functions emulator broke when client request disconnects (#5783 )
Original file line number Diff line number Diff line change @@ -161,11 +161,20 @@ export class RuntimeWorker {
161161 }
162162 const proxy = http . request ( reqOpts , ( _resp : http . IncomingMessage ) => {
163163 resp . writeHead ( _resp . statusCode || 200 , _resp . headers ) ;
164+
165+ let finished = false ;
166+ const finishReq = ( event ?: string ) : void => {
167+ this . logger . log ( "DEBUG" , `Finishing up request with event=${ event } ` ) ;
168+ if ( ! finished ) {
169+ finished = true ;
170+ onFinish ( ) ;
171+ resolve ( ) ;
172+ }
173+ } ;
174+ _resp . on ( "pause" , ( ) => finishReq ( "pause" ) ) ;
175+ _resp . on ( "close" , ( ) => finishReq ( "close" ) ) ;
164176 const piped = _resp . pipe ( resp ) ;
165- piped . on ( "finish" , ( ) => {
166- onFinish ( ) ;
167- resolve ( ) ;
168- } ) ;
177+ piped . on ( "finish" , ( ) => finishReq ( "finish" ) ) ;
169178 } ) ;
170179 proxy . on ( "timeout" , ( ) => {
171180 this . logger . log (
You can’t perform that action at this time.
0 commit comments