File tree Expand file tree Collapse file tree 1 file changed +17
-13
lines changed
packages/browser-playwright/src Expand file tree Collapse file tree 1 file changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -136,19 +136,21 @@ export class PlaywrightBrowserProvider implements BrowserProvider {
136136 }
137137
138138 // make sure the traces are finished if the test hangs
139- process . on ( 'SIGTERM' , ( ) => {
140- if ( ! this . browser ) {
141- return
142- }
143- const promises = [ ]
144- for ( const [ trace , contextId ] of this . pendingTraces . entries ( ) ) {
145- promises . push ( ( ( ) => {
146- const context = this . contexts . get ( contextId )
147- return context ?. tracing . stopChunk ( { path : trace } )
148- } ) ( ) )
149- }
150- return Promise . allSettled ( promises )
151- } )
139+ process . on ( 'SIGTERM' , this . onSIGTERM )
140+ }
141+
142+ private onSIGTERM = ( ) => {
143+ if ( ! this . browser ) {
144+ return
145+ }
146+ const promises = [ ]
147+ for ( const [ trace , contextId ] of this . pendingTraces . entries ( ) ) {
148+ promises . push ( ( ( ) => {
149+ const context = this . contexts . get ( contextId )
150+ return context ?. tracing . stopChunk ( { path : trace } )
151+ } ) ( ) )
152+ }
153+ return Promise . allSettled ( promises )
152154 }
153155
154156 private async openBrowser ( openBrowserOptions : { parallel : boolean } ) {
@@ -545,6 +547,8 @@ export class PlaywrightBrowserProvider implements BrowserProvider {
545547 }
546548
547549 async close ( ) : Promise < void > {
550+ process . off ( 'SIGTERM' , this . onSIGTERM )
551+
548552 debug ?.( '[%s] closing provider' , this . browserName )
549553 this . closing = true
550554 if ( this . browserPromise ) {
You can’t perform that action at this time.
0 commit comments