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

don't wait for networkidle2 unless a reason to #3118

Merged

Conversation

peterbe
Copy link
Contributor

@peterbe peterbe commented Mar 3, 2021

Fixes #3116

Prior to this change I would run yarn test:testing headless and sometimes it would break with:

node:internal/process/promises:218
          triggerUncaughtException(err, true /* fromPromise */);
          ^

Error: Navigation failed because browser has disconnected!
    at CDPSession.<anonymous> (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/puppeteer/lib/LifecycleWatcher.js:46:107)
    at CDPSession.emit (node:events:329:20)
    at CDPSession._onClosed (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/puppeteer/lib/Connection.js:215:10)
    at Connection._onMessage (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/puppeteer/lib/Connection.js:105:17)
    at WebSocket.<anonymous> (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/puppeteer/lib/WebSocketTransport.js:44:24)
    at WebSocket.onMessage (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (node:events:329:20)
    at Receiver.receiverOnMessage (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/ws/lib/websocket.js:789:20)
    at Receiver.emit (node:events:329:20)
    at Receiver.dataMessage (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/ws/lib/receiver.js:422:14)
  -- ASYNC --
    at Frame.<anonymous> (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/puppeteer/lib/helper.js:111:15)
    at Page.waitForNavigation (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/puppeteer/lib/Page.js:692:49)
    at Page.waitForNavigation (/Users/peterbe/dev/MOZILLA/MDN/yari/node_modules/puppeteer/lib/helper.js:112:23)
    at Object.<anonymous> (/Users/peterbe/dev/MOZILLA/MDN/yari/testing/tests/headless.test.js:35:16)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
error Command failed with exit code 1.

That error Navigation failed because browser has disconnected! supposedly "means that the node scripts that launched Puppeteer ends without waiting for the Puppeteer actions to be completed.".
So there's something that attempts to close the jest tests without giving the expect-puppeteer a chance to close the browser instance.

I'm more and more unimpressed with expected-puppeteer. It feels like walking on egg shells. And when certain errors happen sometimes, you have no idea where/which line in your *.test.js code that started the headless chrome crashes.

@peterbe
Copy link
Contributor Author

peterbe commented Mar 3, 2021

@schalkneethling @escattone I'm going merge this if/when the CI goes green.

@peterbe peterbe merged commit 3c90b0e into mdn:main Mar 3, 2021
@peterbe peterbe deleted the 3116-dont-wait-for-networkidle2-unless-a-reason-to branch March 3, 2021 19:59
peterbe added a commit to peterbe/yari that referenced this pull request Jun 1, 2021
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

Successfully merging this pull request may close these issues.

Sporadic errors in headless tests relating to switching language
2 participants