@@ -28,6 +28,7 @@ export class RecorderController {
2828 private _performingAction = false ;
2929 private _pageAliases = new Map < Page , string > ( ) ;
3030 private _lastPopupOrdinal = 0 ;
31+ private _timers = new Set < NodeJS . Timeout > ( ) ;
3132
3233 constructor ( context : BrowserContextBase , output : Writable ) {
3334 this . _output = new TerminalOutput ( output || process . stdout ) ;
@@ -49,6 +50,12 @@ export class RecorderController {
4950 page . on ( Events . Page . FrameNavigated , ( frame : frames . Frame ) => this . _onFrameNavigated ( frame ) ) ;
5051 page . on ( Events . Page . Popup , ( popup : Page ) => this . _onPopup ( page , popup ) ) ;
5152 } ) ;
53+
54+ context . once ( Events . BrowserContext . Close , ( ) => {
55+ for ( const timer of this . _timers )
56+ clearTimeout ( timer ) ;
57+ this . _timers . clear ( ) ;
58+ } ) ;
5259 }
5360
5461 private async _performAction ( frame : frames . Frame , action : actions . Action ) {
@@ -70,7 +77,11 @@ export class RecorderController {
7077 if ( action . name === 'select' )
7178 await frame . selectOption ( action . selector , action . options ) ;
7279 this . _performingAction = false ;
73- setTimeout ( ( ) => action . committed = true , 5000 ) ;
80+ const timer = setTimeout ( ( ) => {
81+ action . committed = true ;
82+ this . _timers . delete ( timer ) ;
83+ } , 5000 ) ;
84+ this . _timers . add ( timer ) ;
7485 }
7586
7687 private async _recordAction ( frame : frames . Frame , action : actions . Action ) {
0 commit comments