Skip to content

Commit

Permalink
fix: newPage api
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyuujin committed Sep 3, 2024
1 parent 6d609ed commit 159e7e1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions apps/peatix-adapter/src/puppeteer/puppeteer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ export class PuppeteerService implements IPuppeteerService {
): Promise<BrowserAndPage> {
const browser = await this.generateBrowser()

const pages = await browser.pages()
const [page] = pages
const page = await browser.newPage()
// const [page] = pages
if (!page) throw new Error('Tab is not created.')

if (!requestHandler) return { browser, page }

await Promise.all(
pages.map(async (page) => {
await page.setRequestInterception(true)
page.on('request', requestHandler)
}),
)
await page.setRequestInterception(true)
page.on('request', requestHandler)
// await Promise.all(
// pages.map(async (page) => {
// await page.setRequestInterception(true)
// page.on('request', requestHandler)
// }),
// )

browser.on('targetcreated', async (target: Target) => {
const page = await target.page()
Expand Down

0 comments on commit 159e7e1

Please sign in to comment.