puppeteer: TypeError: Cannot read property 'call' of null
This gets tricky since I can’t really provide you the best steps to reproduce. We have a flow that opens in a popup. Once you click the final “Done” button, it dismisses the popup. In the latest versions of Puppeteer (1.12.0+) this seems to also close the page that opened the popup (This should not be happening. This page should redirect.)
This issue does NOT occur on Puppeteer 1.10.0. (I suspect the issue may actually lie in Chromium, but figured I’d start here.)
Tell us about your environment:
- Puppeteer version: 1.13.0
- Platform / OS version: macOS 10.14.2
- Node.js version: 10.15.0
What steps will reproduce the problem?
I can’t really provide a code snippet, but essentially we perform a page.click(doneButton);
, the click is successful, then after a second or two both the popup, and the original page are torn down (the entire browser, actually) and this error is thrown:
TypeError: Cannot read property 'call' of null
at DOMWorld._setContext (../../node_modules/puppeteer/lib/DOMWorld.js:61:36)
at FrameManager._onExecutionContextCreated (../../node_modules/puppeteer/lib/FrameManager.js:303:13)
at CDPSession.FrameManager._client.on.event (../../node_modules/puppeteer/lib/FrameManager.js:52:70)
at CDPSession._onMessage (../../node_modules/puppeteer/lib/Connection.js:200:12)
at Connection._onMessage (../../node_modules/puppeteer/lib/Connection.js:112:17)
at WebSocketTransport._ws.addEventListener.event (../../node_modules/puppeteer/lib/WebSocketTransport.js:41:24)
at WebSocket.onMessage (../../node_modules/ws/lib/event-target.js:120:16)
at Receiver.receiverOnMessage (../../node_modules/ws/lib/websocket.js:741:20)
I’m aware this is probably not enough to go on, so if there are additional logs that I can grab (and you can provide me with instructions on how to grab them) I’d be happy to provide some more logging.
What is the expected result? Original page should remain and redirect.
What happens instead? Original page is destroyed and the entire browser instance is closed.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 17 (6 by maintainers)
Commits related to this issue
- fix: gracefully handle multiple contexts for secondary DOM World In case of multiple sessions to the same target, there's a race between sessions to create a secondary isolated world. As a result, we... — committed to aslushnikov/puppeteer by aslushnikov 5 years ago
- fix: gracefully handle multiple contexts for secondary DOM World (#4276) In case of multiple sessions to the same target, there's a race between sessions to create a secondary isolated world. As a r... — committed to puppeteer/puppeteer by aslushnikov 5 years ago
My tests start failing today with the exact same errors (early termination). I’m using puppeteer with browserless
it’s still happening for me and 1.14
hi @joelgriffith, just tried your pull request myself however it doesnt look like that has fixed anything for me. still seeing
I can confirm it’s happening randomly as well inside of browserless. Randomly seeing it on 1.13.0, haven’t tried 1.14.0 yet. For me, it happens when listening to
browser.on('targetcreated')
event and doing operations on the target if it’s a page. It’s incredibly hard to reliably reproduce, but I’ll try using a debug statement.Here’s a dump of protocol messages:
EDITED: Smaller example
Another info byte: apparently these flows run locally just fine (with Puppeteer 1.13.0 as well) in
headless: true
mode. This behavior appears consistent.(Edit: forgot to mention I work with @weworkwithzoh, though that may have been implied 😃)
Adding some more context: the flow in question is a well-known 3rd party login provider, that is supposed to close the popup and redirect the originating window. We’re using the normal
jest-puppeteer
preset with no custom configuration or anything. The outcome depends on whether or not we’re running the flow manually, automatically (via Puppeteer), or automatically as part of our regular CI process. To be precise, here’s our current experience:TypeError: Cannot read property 'call' of null
)Chromium flags as generated by Puppeteer (redacted):
Hope this adds some context, we’d be more than happy to produce more logs, run experiments, basically anything short of sharing the codebase 😃