File tree Expand file tree Collapse file tree 3 files changed +20
-16
lines changed Expand file tree Collapse file tree 3 files changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -339,7 +339,11 @@ async function createProfile(
339339 cdp : CDPSession ,
340340 targetFilename = "" ,
341341) {
342- await cdp . send ( "Network.clearBrowserCache" ) ;
342+ try {
343+ await cdp . send ( "Network.clearBrowserCache" ) ;
344+ } catch ( e ) {
345+ logger . warn ( "Error clearing cache" , e , "browser" ) ;
346+ }
343347
344348 await browser . close ( ) ;
345349
@@ -546,7 +550,8 @@ class InteractiveBrowser {
546550 return ;
547551 }
548552
549- const cookies = await this . browser . getCookies ( this . page ) ;
553+ const cookies = await this . browser . getCookies ( ) ;
554+
550555 for ( const cookieOrig of cookies ) {
551556 // eslint-disable-next-line @typescript-eslint/no-explicit-any
552557 const cookie = cookieOrig as any ;
@@ -566,7 +571,7 @@ class InteractiveBrowser {
566571 cookie . url = url ;
567572 }
568573 }
569- await this . browser . setCookies ( this . page , cookies ) ;
574+ await this . browser . setCookies ( cookies ) ;
570575 // eslint-disable-next-line @typescript-eslint/no-explicit-any
571576 } catch ( e : any ) {
572577 logger . error ( "Save Cookie Error: " , e ) ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import puppeteer, {
2222 Page ,
2323 LaunchOptions ,
2424 Viewport ,
25+ CookieData ,
2526} from "puppeteer-core" ;
2627import { CDPSession , Target , Browser as PptrBrowser } from "puppeteer-core" ;
2728import { Recorder } from "./recorder.js" ;
@@ -616,14 +617,12 @@ export class Browser {
616617 await page . setViewport ( params ) ;
617618 }
618619
619- async getCookies ( page : Page ) {
620- return await page . cookies ( ) ;
620+ async getCookies ( ) {
621+ return ( await this . browser ?. cookies ( ) ) || [ ] ;
621622 }
622623
623- // TODO: Fix this the next time the file is edited.
624- // eslint-disable-next-line @typescript-eslint/no-explicit-any
625- async setCookies ( page : Page , cookies : any ) {
626- return await page . setCookie ( ...cookies ) ;
624+ async setCookies ( cookies : CookieData [ ] ) {
625+ return await this . browser ?. setCookie ( ...cookies ) ;
627626 }
628627}
629628
Original file line number Diff line number Diff line change @@ -153,13 +153,6 @@ export async function initProxy(
153153 privateKeyFile = privateKeyFile || sshProxyPrivateKeyFile ;
154154 publicHostsFile = publicHostsFile || sshProxyKnownHostsFile ;
155155
156- logger . debug ( "Initing proxy" , {
157- url : getSafeProxyString ( proxyUrl ) ,
158- localPort,
159- privateKeyFile,
160- publicHostsFile,
161- } ) ;
162-
163156 const entry = await initSingleProxy (
164157 proxyUrl ,
165158 localPort ++ ,
@@ -200,6 +193,13 @@ export async function initSingleProxy(
200193 sshProxyPrivateKeyFile ?: string ,
201194 sshProxyKnownHostsFile ?: string ,
202195) : Promise < { proxyUrl : string ; dispatcher : Dispatcher } > {
196+ logger . debug ( "Initing proxy" , {
197+ url : getSafeProxyString ( proxyUrl ) ,
198+ localPort,
199+ sshProxyPrivateKeyFile,
200+ sshProxyKnownHostsFile,
201+ } ) ;
202+
203203 if ( proxyUrl && proxyUrl . startsWith ( "ssh://" ) ) {
204204 proxyUrl = await runSSHD (
205205 proxyUrl ,
You can’t perform that action at this time.
0 commit comments