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
frame.evaluate
freezes / hangs on detached frames.
#3261
Comments
Seeing this problem in the wild - especially on sites which runs programmatic ads. It seems const frames = frame.childFrames()
for (const frame of frames) {
// this happens, which makes me wonder if it can happen later
if ( frame.isDetached() ) {
continue
}
await frame.evaluate(() => ...)
// can the frame detach between these async calls?
await frame.evaluate(() => ...)
} Wondering if I have to check before every |
Since have a runner class per class Runner {
private internalFrame
get frame() {
if ( this.internalFrame.isDetached() ) {
throw new Error(`Frame is detached - cannot access`)
}
return this.internalFrame
}
constructor(frame, ...) {
this.internalFrame = frame
}
async run() {
// ...
try {
await this.frame.evaluate(/* ... */)
} catch (e) {
/** Catch errors, including detached frames */
}
} @aslushnikov appreciate if this can be fixed in Puppeteer / Chromium. |
Repro script:
If you un-comment the last
.evaluate
, the code hangs whereas it should not. I guess it should raise an error likeDetachedFrameEvalutionError
or something similar to allow to catch it. Note that you can check manuallyframe.isDetached()
to avoid the call toevaluate
but IMHO:try-catch
to catch all the detached frame errors (and give up with this frame) than to put the check around each call toevaluate
.Thanks!
The text was updated successfully, but these errors were encountered: