Skip to content

Commit

Permalink
Wait network idle event before attempt to create a PDF
Browse files Browse the repository at this point in the history
Also increases the timeout a bit
  • Loading branch information
rmehner committed Apr 11, 2022
1 parent f5d7156 commit a3c12a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lucky-tomatoes-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-to-dead-trees": patch
---

Wait for network idle event before creating pdf
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const createPDF = async (url: string, options?: PdfOptions) => {
const browser = await playwright.chromium.launch();
const context = await browser.newContext({ ignoreHTTPSErrors: true });
const page = await context.newPage();
await page.goto(url);
await page.goto(url, { timeout: 60000 });
await page.waitForLoadState("networkidle");

const pdf = await page.pdf(options);
await browser.close();
Expand Down

0 comments on commit a3c12a4

Please sign in to comment.