Skip to content

Commit

Permalink
Fix "cdpSession.send: Target page, context or browser has been closed"
Browse files Browse the repository at this point in the history
  • Loading branch information
alucarded committed Dec 6, 2023
1 parent 39248f1 commit 6bd2697
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@ export function createPageShim(page: pw.Page | pw.Frame) {
if (prop === '_client') {
return () => ({
send: async (method: string, params: any) => {
const session = await getPageCDPSession(page)
return await session.send(method as any, params)
try {
const session = await getPageCDPSession(page)
return await session.send(method as any, params)
} catch (err: any) {
debug('page shim: error when sending:', err.message)
return Promise.resolve()
}
},
on: (event: string, listener: any) => {
getPageCDPSession(page).then(session => {
Expand Down

0 comments on commit 6bd2697

Please sign in to comment.