Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support timeout for page.pdf() call #7508

Merged
merged 14 commits into from Sep 14, 2021
Merged

feat: support timeout for page.pdf() call #7508

merged 14 commits into from Sep 14, 2021

Conversation

nikli2009
Copy link
Contributor

@nikli2009 nikli2009 commented Aug 19, 2021

Context

When use page.pdf API, there are some extreme scenarios that can cause the promise never get fulfilled or rejected. Hence this may cause potential problems. These kind of errors most likely happens in Chromium.

Related Issues

Changes

  • Added timeout parameter for PDFOption which will be used in page.pdf call

@google-cla
Copy link

google-cla bot commented Aug 19, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Aug 19, 2021
@nikli2009
Copy link
Contributor Author

@googlebot I signed it!

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Aug 19, 2021
Copy link
Contributor

@jschfflr jschfflr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move to timeout to createPDFStream as it looks like the Page.printToPDF call there is the original source of the timeout?

@jschfflr
Copy link
Contributor

Do you know if there's a corresponding bug reported for Chromium already? And if not, file one on https://crbug.com/new?
That way, we can make sure that we can also address the problem at its source. Thanks!

@nikli2009
Copy link
Contributor Author

Can you move to timeout to createPDFStream as it looks like the Page.printToPDF call there is the original source of the timeout?

Sounds good ! Thanks for the review

@nikli2009
Copy link
Contributor Author

Do you know if there's a corresponding bug reported for Chromium already? And if not, file one on https://crbug.com/new?
That way, we can make sure that we can also address the problem at its source. Thanks!

np, will check on that .

@nikli2009
Copy link
Contributor Author

☑️ Issue created for Chromium

@jschfflr
Copy link
Contributor

Awesome, thanks!
As we wanna make sure that the timeout still works when the bug is eventually fixed in Chromium, the tests should be updated to just use a timeout of 1 and make sure that the call times out. That's how we test the other time outs too.
As for the test that you already wrote: It's a great reproduction that you can maybe put in a gist and reference it in the Chromium bug. That will help the engineer who'll be resolving the issue there a ton!

@nikli2009
Copy link
Contributor Author

Awesome, thanks!
As we wanna make sure that the timeout still works when the bug is eventually fixed in Chromium, the tests should be updated to just use a timeout of 1 and make sure that the call times out. That's how we test the other time outs too.
As for the test that you already wrote: It's a great reproduction that you can maybe put in a gist and reference it in the Chromium bug. That will help the engineer who'll be resolving the issue there a ton!

Yep, the timeout values in tests are 1.
gist has been created and linked to the Chromium issue :D

Let me know if there are other things I could help with and thanks for taking time review my PR 😄

test/page.spec.ts Outdated Show resolved Hide resolved
test/assets/pdf.html Outdated Show resolved Hide resolved
@jschfflr
Copy link
Contributor

@nikli2009 Thanks for updating the pull request! I left two more comments to reduce the size of the pr a bit - could you address them too?

@nikli2009
Copy link
Contributor Author

@nikli2009 Thanks for updating the pull request! I left two more comments to reduce the size of the pr a bit - could you address them too?

Happy to :D

@nikli2009
Copy link
Contributor Author

nikli2009 commented Sep 13, 2021

@nikli2009 Thanks for updating the pull request! I left two more comments to reduce the size of the pr a bit - could you address them too?

@jschfflr Thanks for the review :D, got some quick updates :

  1. After some manual tests, it seems that the printToPDF call only hangs when using base64(valid base64 tho) and external url at same time.
  2. Removed those problematic headerTemplate config in the tests. I realized that as we set the timeout to be 1 ms and it will just always timeout (even when printToPDF being executed normally).

Copy link
Contributor

@jschfflr jschfflr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, right. Good catch!

@jschfflr jschfflr enabled auto-merge (squash) September 14, 2021 13:53
@jschfflr jschfflr merged commit f90af66 into puppeteer:main Sep 14, 2021
jschfflr pushed a commit to mushishi78/puppeteer that referenced this pull request Sep 16, 2021
This was referenced May 30, 2022
This was referenced May 30, 2022
y-yagi added a commit to y-yagi/puppeteer that referenced this pull request Oct 24, 2022
… disable it

This was mentioned in the PR that adding this feature puppeteer#7508
But it has lost at puppeteer#8593.

I'm not sure why this was removed, but I think this info is useful for users.
y-yagi added a commit to y-yagi/puppeteer that referenced this pull request Oct 26, 2022
This was mentioned in the PR that adding this feature puppeteer#7508
But it has lost at puppeteer#8593.

I'm not sure why this was removed, but I think this info is useful for users.
OrKoN pushed a commit to y-yagi/puppeteer that referenced this pull request Nov 3, 2022
This was mentioned in the PR that adding this feature puppeteer#7508
But it has lost at puppeteer#8593.

I'm not sure why this was removed, but I think this info is useful for users.
OrKoN pushed a commit to y-yagi/puppeteer that referenced this pull request Dec 12, 2022
This was mentioned in the PR that adding this feature puppeteer#7508
But it has lost at puppeteer#8593.

I'm not sure why this was removed, but I think this info is useful for users.
OrKoN pushed a commit to y-yagi/puppeteer that referenced this pull request Dec 12, 2022
This was mentioned in the PR that adding this feature puppeteer#7508
But it has lost at puppeteer#8593.

I'm not sure why this was removed, but I think this info is useful for users.
OrKoN pushed a commit that referenced this pull request Dec 12, 2022
**What kind of change does this PR introduce?**

Add how to disable timeout for `page.pdf()`.

**Summary**

This was mentioned in the PR that adding this feature
#7508 But it has lost at
#8593.

I'm not sure why this was removed, but I think this info is useful for
users.

**Does this PR introduce a breaking change?**

no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants