File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -334,15 +334,11 @@ export class Instagram<PostType> {
334334 protected async stop ( ) {
335335 await this . progress ( Progress . CLOSING ) ;
336336
337- // Close page and browser
337+ // Remove listeners
338338 if ( ! this . page . isClosed ( ) ) {
339339 this . page . removeAllListeners ( "request" ) ;
340340 this . page . removeAllListeners ( "response" ) ;
341341 this . page . removeAllListeners ( "requestfailed" ) ;
342- await this . page . close ( ) ;
343- }
344- if ( this . finished && ! this . browserDisconnected ) {
345- await this . browser . close ( ) ;
346342 }
347343
348344 // Clear request buffers
@@ -354,6 +350,15 @@ export class Instagram<PostType> {
354350 await this . responseBufferLock . acquireAsync ( ) ;
355351 this . responseBuffer = [ ] ;
356352 this . responseBufferLock . release ( ) ;
353+
354+ // Close page
355+ if ( ! this . page . isClosed ( ) ) {
356+ await this . page . close ( ) ;
357+ }
358+
359+ if ( this . finished && ! this . browserDisconnected ) {
360+ await this . browser . close ( ) ;
361+ }
357362 }
358363
359364 /**
Original file line number Diff line number Diff line change @@ -126,7 +126,6 @@ export class Search extends Instagram<TSearchResult> {
126126 await this . stop ( ) ;
127127 throw e ;
128128 }
129-
130129 await this . stop ( ) ;
131130 return this . searchResult ;
132131 }
You can’t perform that action at this time.
0 commit comments