File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/lib/server/websearch/scrape Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { PlaywrightBlocker } from "@cliqz/adblocker-playwright";
10
10
import { env } from "$env/dynamic/private" ;
11
11
12
12
// Singleton initialized by initPlaywrightService
13
- let playwrightService : Promise < { ctx : BrowserContext ; blocker : PlaywrightBlocker } > ;
13
+ let playwrightService : Promise < { ctx : BrowserContext ; blocker : PlaywrightBlocker } > | undefined ;
14
14
15
15
async function initPlaywrightService ( ) {
16
16
if ( playwrightService ) return playwrightService ;
@@ -42,6 +42,12 @@ async function initPlaywrightService() {
42
42
if ( env . WEBSEARCH_JAVASCRIPT === "false" ) return mostBlocked . blockScripts ( ) ;
43
43
return mostBlocked ;
44
44
} ) ;
45
+
46
+ // Clear the singleton when the context closes
47
+ ctx . on ( "close" , ( ) => {
48
+ playwrightService = undefined ;
49
+ } ) ;
50
+
45
51
return Object . freeze ( { ctx, blocker } ) ;
46
52
}
47
53
You can’t perform that action at this time.
0 commit comments