Commit 7729713e authored by nanahira's avatar nanahira

Update src/puppeteer/puppeteer.service.ts

parent e52b3901
Pipeline #37414 passed with stages
in 16 minutes and 35 seconds
...@@ -35,10 +35,12 @@ export class PuppeteerService ...@@ -35,10 +35,12 @@ export class PuppeteerService
action: (page: Page) => Promise<T>, action: (page: Page) => Promise<T>,
) { ) {
const page = await this.browser.newPage(); const page = await this.browser.newPage();
await page.goto(url, { waitUntil: 'networkidle0', timeout: 300000 }); try {
const result = await action(page); await page.goto(url, { waitUntil: 'networkidle0', timeout: 300000 });
await page.close(); return await action(page);
return result; } finally {
await page.close();
}
} }
render(url: string) { render(url: string) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment