playwright: [BUG] Firefox: `TypeError: Cannot read properties of undefined (reading 'childFrames')`

Preface: I’m using playwright for large scale academic web measurements, which I know is not what playwright was built for. I’ve done a fair share of FOSS work myself, so you have my full sympathies if you consider hard-to-reproduce crashes from unsupported use-cases out of scope for the time being - I can easily work around them. That being said, I was originally about to report five different tracebacks here, just to notice that @dgozman fixed four of them in #9826 a few hours ago. 😄🍰 So my presumption is you may find this interesting, which is why I’m sharing the remaining one here.


I’ve encountered the following crash with 1.16.0-next-alpha-oct-20-2021 running Firefox on Ubuntu 20.04. Unfortunately there are no good repros - this happens very rarely and seemingly at random. For reference, I’ve seen it five times during ~70k website visits made with Firefox. For comparison, this is about as often as the various context-is-undefined crashes fixed in #9826.

2021-10-23T02:32:29.114Z pw:browser [pid=1135] <kill>
2021-10-23T02:32:29.114Z pw:browser [pid=1135] <will force kill>
2021-10-23T02:32:29.121Z pw:browser [pid=1135] starting temporary directories cleanup
/root/node_modules/playwright-core/lib/server/frames.js:337
    for (const child of frame.childFrames()) this._removeFramesRecursively(child);
                              ^

TypeError: Cannot read properties of undefined (reading 'childFrames')
    at FrameManager.removeChildFramesRecursively (/root/node_modules/playwright-core/lib/server/frames.js:337:31)
    at FrameManager.frameCommittedNewDocumentNavigation (/root/node_modules/playwright-core/lib/server/frames.js:169:10)
    at FFPage._onNavigationCommitted (/root/node_modules/playwright-core/lib/server/firefox/ffPage.js:211:30)
    at FFSession.emit (node:events:390:28)
    at /root/node_modules/playwright-core/lib/server/firefox/ffConnection.js:247:41

I have also done about 70k website crawls with Chromium and Webkit each without observing a crash at this location, so this seems Firefox-specific.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 19 (4 by maintainers)

Most upvoted comments

@mxschmitt I believe I encountered the same bug. Here is the minimal reproducible example I can get:

The buggy webpage test.html:

<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <iframe src="http://www.foxyform.com/"></iframe>
    <script type="text/javascript" src="foo.js"></script>
  </body>
</html>

Sample code:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.firefox.launch()
    page = browser.new_page()
    page.set_viewport_size({"width": 1080, "height": 1920})
    page.goto("file:///data/test.html")
    browser.close()

I used docker image to reproduce the error:

$ docker run -v "$PWD:/data" -it --rm mcr.microsoft.com/playwright/python:v1.21.0-focal python /data/run.py
/usr/local/lib/python3.8/dist-packages/playwright/driver/package/lib/server/frames.js:339
    for (const child of frame.childFrames()) this._removeFramesRecursively(child);
                              ^

TypeError: Cannot read properties of undefined (reading 'childFrames')
    at FrameManager.removeChildFramesRecursively (/usr/local/lib/python3.8/dist-packages/playwright/driver/package/lib/server/frames.js:339:31)
    at FrameManager.frameCommittedNewDocumentNavigation (/usr/local/lib/python3.8/dist-packages/playwright/driver/package/lib/server/frames.js:171:10)
    at FFPage._onNavigationCommitted (/usr/local/lib/python3.8/dist-packages/playwright/driver/package/lib/server/firefox/ffPage.js:214:30)
    at FFSession.emit (node:events:390:28)
    at /usr/local/lib/python3.8/dist-packages/playwright/driver/package/lib/server/firefox/ffConnection.js:247:41

For the record: this bug happens due to Juggler failing to find parent frames for certain iframes. This fundamentally seems to be related to us tracking docShell hierarchies instead of more modern browsingContext trees.

This should be fixed with our fission support.

So far I am still seeing this issue after using next 1.28

I just experienced what it looks like the same crash with latest version of PW (1.17.2) and also using Firefox

...../node_modules/playwright-core/lib/server/frames.js:339
    for (const child of frame.childFrames()) this._removeFramesRecursively(child);
                              ^

TypeError: Cannot read properties of undefined (reading 'childFrames')
    at FrameManager.removeChildFramesRecursively (...../node_modules/playwright-core/lib/server/frames.js:339:31)
    at FrameManager.frameCommittedNewDocumentNavigation (...../node_modules/playwright-core/lib/server/frames.js:171:10)
    at FFPage._onNavigationCommitted (...../node_modules/playwright-core/lib/server/firefox/ffPage.js:212:30)
    at FFSession.emit (node:events:390:28)
    at ...../node_modules/playwright-core/lib/server/firefox/ffConnection.js:247:41

Trying to click on the accept button of some cookie consent overlay dialog box with:

let ctxCookies = await ctx.cookies('https://www.pap.fr');
let consent = ctxCookies.find(x => x.name == 'euconsent-v2');
if (consent === undefined || !consent.value)
  await page.click(':nth-match(button:has-text("Tout accepter et continuer"), 2)', {timeout: 2000});      

Thank you for the issue! You are right that random crash without a reliable repro is not something we’d prioritize. I’m glad to hear that other issues are being fixed though 😄

I’ll leave the issue open, just in case someone encounters a reliable repro - could be 1 out of 100, but with a script we can run locally.