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

TypeError: Cannot read property 'call' of null #4197

Closed
weworkwithzoh opened this issue Mar 22, 2019 · 17 comments
Closed

TypeError: Cannot read property 'call' of null #4197

weworkwithzoh opened this issue Mar 22, 2019 · 17 comments

Comments

@weworkwithzoh
Copy link

weworkwithzoh commented Mar 22, 2019

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.

@holograph
Copy link

holograph commented Mar 26, 2019

(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:

  • Running locally on MacOS Mojave with Puppeteer 1.10.0 - passes
  • Running locally on MacOS Mojave with Puppeteer 1.13.0 - fails (TypeError: Cannot read property 'call' of null)
  • Running manually on MacOS Mojave with Puppeteer 1.13.0's version of Chromium (I've dumped the Puppeteer flags, see below) - passes
    • Running on CI (Linux/Dockerized) with Puppeteer 1.10.0 - fails (random timeout)
    • Running on CI (Linux/Dockerized) with Puppeteer 1.13.0 - fails (random timeout)

Chromium flags as generated by Puppeteer (redacted):

/Users/myuser/dev/projectname/node_modules/puppeteer/.local-chromium/mac-637110/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=site-per-process,TranslateUI,BlinkGenPropertyTrees --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --safebrowsing-disable-auto-update --enable-automation --password-store=basic --use-mock-keychain about:blank --user-agent=Chrome --no-sandbox --disable-setuid-sandbox --disable-popup-blocking --incognito --window-size=1440,900 --remote-debugging-port=0 --user-data-dir=--user-data-dir=/var/folders/jz/nwn1s1ls3x73j55bs87fcrlc0000gp/T/puppeteer_dev_profile-Lg0yCg

Hope this adds some context, we'd be more than happy to produce more logs, run experiments, basically anything short of sharing the codebase :-)

@holograph
Copy link

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.

@weworkwithzoh
Copy link
Author

Welp, this appears to have been resolved by 1.14.0... Guess we can close this.

@jeremymarc
Copy link

it's still happening for me and 1.14

@weworkwithzoh
Copy link
Author

Jeremy, are you hitting this with a redirect/early termination like we were. or something else?

@jeremymarc
Copy link

My tests start failing today with the exact same errors (early termination). I'm using puppeteer with browserless

(node:57) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'call' of null
    at DOMWorld._setContext (/opt/app/node_modules/puppeteer/lib/DOMWorld.js:61:36)
    at FrameManager._onExecutionContextCreated (/opt/app/node_modules/puppeteer/lib/FrameManager.js:303:13)
    at CDPSession.FrameManager._client.on.event (/opt/app/node_modules/puppeteer/lib/FrameManager.js:52:70)
    at CDPSession.emit (events.js:193:13)
    at CDPSession._onMessage (/opt/app/node_modules/puppeteer/lib/Connection.js:200:12)
    at Connection._onMessage (/opt/app/node_modules/puppeteer/lib/Connection.js:112:17)
    at WebSocketTransport._ws.addEventListener.event (/opt/app/node_modules/puppeteer/lib/WebSocketTransport.js:41:24)
    at WebSocket.onMessage (/opt/app/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:193:13)
    at Receiver.receiverOnMessage (/opt/app/node_modules/ws/lib/websocket.js:741:20)

@weworkwithzoh weworkwithzoh reopened this Apr 3, 2019
@weworkwithzoh
Copy link
Author

In that case, I'll go ahead and reopen this issue so we can get more visibility into it.

@aslushnikov
Copy link
Contributor

@jeremymarc can you reproduce the failure reliably? If you can, a log of protocol messages (puppeteer ran with DEBUG=* env variable) would help a lot.

@james-berry
Copy link

james-berry commented Apr 10, 2019

also experiencing this (1.13)

EDIT: Just upgraded to version 1.14 - Error still the same

@xse
Copy link

xse commented Apr 10, 2019

Hey, i believe that i'm seeing that error too.

  • node: v11.13.0
  • puppeteer: 1.14.0

It's occuring randomly and for me at least it's seems unrelated to any action in particular in fact it's happening before any of my calls for page.goto.

@aslushnikov I did manage to log an instance where it happened here : https://gist.github.com/xse/029eda0c2204799313b1b1a5c6d35249 (line 276)
The actual log is longer than that but i guess the rest of it is unrelated to this issue.

I still cannot reliably reproduce it i just know that if i keep killing and relaunching my application it'll come out at some point. (screenshot)

EDIT: i can push the actual code if you guys need a way to reproduce it, however be aware that it's really random like i can launch that thing 100x without getting any errors and two days later i might get 5 in a row.

@joelgriffith
Copy link
Contributor

joelgriffith commented Apr 10, 2019

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:

puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"c6dff360-1106-4660-b4aa-59364ac5130c","type":"browser","title":"","url":"","attached":false}}} +10ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"c6dff360-1106-4660-b4aa-59364ac5130c","type":"browser","title":"","url":"","attached":true}}} +0ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"03718C5A63E08AEC53FEBAD801D99D29","type":"page","title":"","url":"","attached":false,"browserContextId":"185273DBDFFF6BB24E37F02DE083FDA3"}}} +3ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"1C4543CEC50CF0C8BC09834776A40513","type":"page","title":"about:blank","url":"about:blank","attached":false,"browserContextId":"185273DBDFFF6BB24E37F02DE083FDA3"}}} +39ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"03718C5A63E08AEC53FEBAD801D99D29","type":"page","title":"about:blank","url":"about:blank","attached":false,"browserContextId":"185273DBDFFF6BB24E37F02DE083FDA3"}}} +20ms
  puppeteer:protocol SEND ► {"method":"Target.attachToTarget","params":{"targetId":"03718C5A63E08AEC53FEBAD801D99D29","flatten":true},"id":2} +0ms
  puppeteer:protocol ◀ RECV {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"03718C5A63E08AEC53FEBAD801D99D29","type":"page","title":"about:blank","url":"about:blank","attached":true,"browserContextId":"185273DBDFFF6BB24E37F02DE083FDA3"}}} +1ms
  puppeteer:protocol ◀ RECV {"method":"Target.attachedToTarget","params":{"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","targetInfo":{"targetId":"03718C5A63E08AEC53FEBAD801D99D29","type":"page","title":"about:blank","url":"about:blank","attached":true,"browserContextId":"185273DBDFFF6BB24E37F02DE083FDA3"},"waitingForDebugger":false}} +0ms
  puppeteer:protocol ◀ RECV {"id":2,"result":{"sessionId":"A51E2AAB47D750A158B233985A1F8F8E"}} +0ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Page.enable","params":{},"id":3} +0ms
  puppeteer:protocol ◀ RECV {"id":3,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +1ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Page.getFrameTree","params":{},"id":4} +1ms
  puppeteer:protocol ◀ RECV {"id":4,"result":{"frameTree":{"frame":{"id":"03718C5A63E08AEC53FEBAD801D99D29","loaderId":"60AB5BC19EBD10DFD0AF02960322ED6F","url":"about:blank","securityOrigin":"://","mimeType":"text/html"}}}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Target.setAutoAttach","params":{"autoAttach":true,"waitForDebuggerOnStart":false,"flatten":true},"id":5} +0ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Page.setLifecycleEventsEnabled","params":{"enabled":true},"id":6} +1ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Network.enable","params":{},"id":7} +14ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Runtime.enable","params":{},"id":8} +0ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Security.enable","params":{},"id":9} +0ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Performance.enable","params":{},"id":10} +1ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Log.enable","params":{},"id":11} +0ms
  puppeteer:protocol ◀ RECV {"id":5,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"method":"Security.securityStateChanged","params":{"securityState":"neutral","schemeIsCryptographic":false,"explanations":[],"insecureContentStatus":{"ranMixedContent":false,"displayedMixedContent":false,"containedMixedForm":false,"ranContentWithCertErrors":false,"displayedContentWithCertErrors":false,"ranInsecureContentStyle":"unknown","displayedInsecureContentStyle":"unknown"},"summary":""}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"id":9,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"03718C5A63E08AEC53FEBAD801D99D29","loaderId":"60AB5BC19EBD10DFD0AF02960322ED6F","name":"commit","timestamp":286891.998493}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"03718C5A63E08AEC53FEBAD801D99D29","loaderId":"60AB5BC19EBD10DFD0AF02960322ED6F","name":"DOMContentLoaded","timestamp":286891.998557}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +16ms
  puppeteer:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"03718C5A63E08AEC53FEBAD801D99D29","loaderId":"60AB5BC19EBD10DFD0AF02960322ED6F","name":"load","timestamp":286891.998701}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"03718C5A63E08AEC53FEBAD801D99D29","loaderId":"60AB5BC19EBD10DFD0AF02960322ED6F","name":"networkAlmostIdle","timestamp":286891.999122}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"03718C5A63E08AEC53FEBAD801D99D29","loaderId":"60AB5BC19EBD10DFD0AF02960322ED6F","name":"networkIdle","timestamp":286891.999122}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"id":6,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +17ms
  puppeteer:protocol ◀ RECV {"id":7,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":1,"origin":"://","name":"","auxData":{"isDefault":true,"type":"default","frameId":"03718C5A63E08AEC53FEBAD801D99D29"}}}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"id":8,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"id":10,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"id":11,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +1ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Page.addScriptToEvaluateOnNewDocument","params":{"source":"//# sourceURL=__puppeteer_evaluation_script__","worldName":"__puppeteer_utility_world__"},"id":12} +0ms
  puppeteer:protocol ◀ RECV {"id":12,"result":{"identifier":"1"}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +1ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Page.createIsolatedWorld","params":{"frameId":"03718C5A63E08AEC53FEBAD801D99D29","grantUniveralAccess":true,"worldName":"__puppeteer_utility_world__"},"id":13} +0ms
  puppeteer:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":2,"origin":"","name":"__puppeteer_utility_world__","auxData":{"isDefault":false,"type":"isolated","frameId":"03718C5A63E08AEC53FEBAD801D99D29"}}}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +2ms
  puppeteer:protocol ◀ RECV {"id":13,"result":{"executionContextId":2}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Emulation.setDeviceMetricsOverride","params":{"mobile":false,"width":800,"height":600,"deviceScaleFactor":1,"screenOrientation":{"angle":0,"type":"portraitPrimary"}},"id":14} +0ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Emulation.setTouchEmulationEnabled","params":{"enabled":false},"id":15} +0ms
  puppeteer:protocol ◀ RECV {"id":14,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +1ms
  puppeteer:protocol ◀ RECV {"id":15,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol SEND ► {"sessionId":"A51E2AAB47D750A158B233985A1F8F8E","method":"Page.setDownloadBehavior","params":{"behavior":"allow","downloadPath":"/var/folders/sf/v91_lddx62d83njrwsh_5qrw0000gn/T"},"id":16} +1ms
  puppeteer:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":3,"origin":"","name":"__puppeteer_utility_world__","auxData":{"isDefault":false,"type":"isolated","frameId":"03718C5A63E08AEC53FEBAD801D99D29"}}}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +0ms
  puppeteer:protocol ◀ RECV {"id":16,"result":{}, "sessionId": "A51E2AAB47D750A158B233985A1F8F8E"} +1ms
(node:50745) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'call' of null
    at DOMWorld._setContext (/Users/joelgriffith/browserless/chrome/node_modules/puppeteer/lib/DOMWorld.js:61:36)
    at FrameManager._onExecutionContextCreated (/Users/joelgriffith/browserless/chrome/node_modules/puppeteer/lib/FrameManager.js:303:13)
    at CDPSession.FrameManager._client.on.event (/Users/joelgriffith/browserless/chrome/node_modules/puppeteer/lib/FrameManager.js:52:70)
    at CDPSession.emit (events.js:182:13)
    at CDPSession._onMessage (/Users/joelgriffith/browserless/chrome/node_modules/puppeteer/lib/Connection.js:200:12)
    at Connection._onMessage (/Users/joelgriffith/browserless/chrome/node_modules/puppeteer/lib/Connection.js:112:17)
    at WebSocketTransport._ws.addEventListener.event (/Users/joelgriffith/browserless/chrome/node_modules/puppeteer/lib/WebSocketTransport.js:41:24)
    at WebSocket.onMessage (/Users/joelgriffith/browserless/chrome/node_modules/puppeteer/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:182:13)
    at Receiver.receiverOnMessage (/Users/joelgriffith/browserless/chrome/node_modules/puppeteer/node_modules/ws/lib/websocket.js:792:20)

EDITED: Smaller example

@weworkwithzoh
Copy link
Author

Yep, can confirm we're still seeing it intermittently on 1.14.
I too, find it happens when using browser.on('targetcreated')

@joelgriffith
Copy link
Contributor

joelgriffith commented Apr 10, 2019

browser.on('targetcreated', async (target) => {
  return target.type() === 'page' ? target.page()
    .then(async (page) => {

Seems like a potential race condition. I'm mucking with newly created pages, but since this callback isn't blocking then downstream consumers of a page can have issues when they try to use a page

@joelgriffith
Copy link
Contributor

joelgriffith commented Apr 10, 2019

Looking at the logs it appears that executionContextCreated is getting called twice for __puppeteer_utility_world__, and looking at the code it appears puppeteer really only expects this to be set once.

My current case is where two instances of puppeteer are talking with the same browser.

@joelgriffith
Copy link
Contributor

joelgriffith commented Apr 10, 2019

Can be reliably reproduced by the following:

const puppeteer = require('puppeteer');

async function run() {
  let browserOne = null;
  let browserTwo = null;

  try {
    browserOne = await puppeteer.launch();
    const browserWSEndpoint = browserOne.wsEndpoint();
    browserOne.on('targetcreated', (target) => target.page());

    browserTwo = await puppeteer.connect({ browserWSEndpoint });

    await browserTwo.newPage();

  } catch(e) {
    console.log(`Saw error:`, e);
  } finally {
    browserOne && browserOne.close();
    browserTwo && browserTwo.close();
  }
}

run();

Kind of an edgecase here where there's two debuggers connected to the same browser. But I'm not certain that's entirely rare...

@joelgriffith
Copy link
Contributor

Think I have a fix here: #4269

@james-berry
Copy link

james-berry commented Apr 11, 2019

hi @joelgriffith, just tried your pull request myself however it doesnt look like that has fixed anything for me. still seeing

puppet_1       | (node:17) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'call' of null
puppet_1       |     at DOMWorld._setContext (/app/puppet/node_modules/puppeteer/lib/DOMWorld.js:61:36)
puppet_1       |     at FrameManager._onExecutionContextCreated (/app/puppet/node_modules/puppeteer/lib/FrameManager.js:319:13)
puppet_1       |     at CDPSession.FrameManager._client.on.event (/app/puppet/node_modules/puppeteer/lib/FrameManager.js:53:70)
puppet_1       |     at CDPSession.emit (events.js:189:13)
puppet_1       |     at CDPSession._onMessage (/app/puppet/node_modules/puppeteer/lib/Connection.js:200:12)
puppet_1       |     at Connection._onMessage (/app/puppet/node_modules/puppeteer/lib/Connection.js:112:17)
puppet_1       |     at WebSocketTransport._ws.addEventListener.event (/app/puppet/node_modules/puppeteer/lib/WebSocketTransport.js:41:24)
puppet_1       |     at WebSocket.onMessage (/app/puppet/node_modules/ws/lib/event-target.js:120:16)
puppet_1       |     at WebSocket.emit (events.js:189:13)
puppet_1       |     at Receiver.receiverOnMessage (/app/puppet/node_modules/ws/lib/websocket.js:789:20)
puppet_1       |     at Receiver.emit (events.js:189:13)
puppet_1       |     at Receiver.dataMessage (/app/puppet/node_modules/ws/lib/receiver.js:422:14)
puppet_1       |     at Receiver.getData (/app/puppet/node_modules/ws/lib/receiver.js:352:17)
puppet_1       |     at Receiver.startLoop (/app/puppet/node_modules/ws/lib/receiver.js:138:22)
puppet_1       |     at Receiver._write (/app/puppet/node_modules/ws/lib/receiver.js:74:10)
puppet_1       |     at doWrite (_stream_writable.js:410:12)
puppet_1       |     at writeOrBuffer (_stream_writable.js:394:5)
puppet_1       |     at Receiver.Writable.write (_stream_writable.js:294:11)
puppet_1       |     at Socket.socketOnData (/app/puppet/node_modules/ws/lib/websocket.js:864:35)
puppet_1       |     at Socket.emit (events.js:189:13)
puppet_1       |     at addChunk (_stream_readable.js:284:12)
puppet_1       |     at readableAddChunk (_stream_readable.js:265:11)

aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Apr 11, 2019
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 might
end up having 2 execution contexts created for the needs of the
secondary isolated world.

This patch starts handling this race gracefully: instead of crashing,
we can use either of the execution contexts and ignore the rest.

Notably, the same race condition might happen if page reloads itself
in-between the calls to `page.addEvaluateOnNewDocument` and
`page.createIsolatedWorld`.

Fixes puppeteer#4197.
aslushnikov added a commit that referenced this issue Apr 11, 2019
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 might
end up having 2 execution contexts created for the needs of the
secondary isolated world.

This patch starts handling this race gracefully: instead of crashing,
we can use either of the execution contexts and ignore the rest.

Notably, the same race condition might happen if page reloads itself
in-between the calls to `page.addEvaluateOnNewDocument` and
`page.createIsolatedWorld`.

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

No branches or pull requests

7 participants