-
Notifications
You must be signed in to change notification settings - Fork 9k
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
[Bug]: Evaluate hangs inside of embedded PDF frames #10696
Comments
The issue has been labeled as confirmed by the automatic analyser. |
The new headless mode is still in beta and there may be stability and compatibility issues. You probably already know this, but just in case, if you're looking for ways to render PDFs while using a headless browser, a reliable solution is:
It's a few steps, but it reliably renders PDFs. However if you're looking specifically to evaluate JS code in the context of PDFs for some "Chrome PDF viewer" plugin enhancement, this method will not help you. That being said, using the convert method described here will enable you to build your own "PDF viewer" fairly simply. For some reference code that works in production (albeit using the underlying DevTools protocol rather than a Puppeteer API, to which you'd need to convert if you wish to use pptr), take a look here for the convert to PDF code; and here, here and here for the capture download and spawn convert process code. All the best @liamdalg ! |
Minimal, reproducible example
Error string
no error
Bug behavior
Background
In new headless or headful mode (i.e., when PDFs are rendered in the browser), attempting to evaluate inside of the PDF frame hangs indefinitely. This is true for any methods which attempt to use the frame's execution context. From some limited debugging, it seems that puppeteer is waiting indefinitely for an execution context that doesn't exist.
Possibly related (?): the CDP event
"Page.frameDetached","params":{"frameId":"31218988D67AB9B8AC1BD6140FCC9433","reason":"swap"}
is fired which, according to theFrameManager
code, means that the frame should now be an OOPIF frame, butframe.isOOPFrame()
returnsfalse
.Debug: hang.log
PDF used (any will work): example.pdf
Expectation
Either:
Reality
Program hangs on
frame.evaluate
. More specifically, it hangs when waiting for the deferred execution context (https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/util/Deferred.ts#L74).Puppeteer configuration file (if used)
No response
Puppeteer version
21.0.1
Node version
18.16.1
Package manager
npm
Package manager version
9.5.1
Operating system
Linux
The text was updated successfully, but these errors were encountered: