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

How to handle cancelling a run from CLI without page crashing? #5735

Closed
chrisheseltine opened this issue Apr 24, 2020 · 6 comments
Closed

How to handle cancelling a run from CLI without page crashing? #5735

chrisheseltine opened this issue Apr 24, 2020 · 6 comments

Comments

@chrisheseltine
Copy link

chrisheseltine commented Apr 24, 2020

What I am aiming to do is super simple, and I'm sure it used to work.

I have built a basic web scraper using Puppeteer with JS, and when I am doing a run, say for testing, I want to cancel that run once I see my new feature is working.

When I do this I get a tonne of nasty error spam about how the page crashed and I didn't handle it.

I have setup listeners on the page object for "error" and "pageerror" events as per the docs but I am still getting this issue. I have also wrapped the entire application in a try/catch.

Does anyone know how to prevent this? Say for example on event "cancel"...

(node:7908) UnhandledPromiseRejectionWarning: Error: Page crashed! at Page._onTargetCrashed (C:\Users\hesel\dev\repo\theseedlist\scrapers\seedsman-com\node_modules\puppeteer\lib\Page.js:215:24) at CDPSession.<anonymous> (C:\Users\hesel\dev\repo\theseedlist\scrapers\seedsman-com\node_modules\puppeteer\lib\Page.js:123:56) at CDPSession.emit (events.js:311:20) at CDPSession._onMessage (C:\Users\hesel\dev\repo\theseedlist\scrapers\seedsman-com\node_modules\puppeteer\lib\Connection.js:200:12) at Connection._onMessage (C:\Users\hesel\dev\repo\theseedlist\scrapers\seedsman-com\node_modules\puppeteer\lib\Connection.js:112:17) at WebSocket.<anonymous> (C:\Users\hesel\dev\repo\theseedlist\scrapers\seedsman-com\node_modules\puppeteer\lib\WebSocketTransport.js:44:24) at WebSocket.onMessage (C:\Users\hesel\dev\repo\theseedlist\scrapers\seedsman-com\node_modules\ws\lib\event-target.js:120:16) at WebSocket.emit (events.js:311:20) at Receiver.receiverOnMessage (C:\Users\hesel\dev\repo\theseedlist\scrapers\seedsman-com\node_modules\ws\lib\websocket.js:789:20) at Receiver.emit (events.js:311:20) (node:7908) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:7908) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. $ ERROR: The process with PID 2752 (child process of PID 7908) could not be terminated. Reason: There is no running instance of the task.

@munrocket
Copy link
Contributor

This problem is was appear in puppeter@v3.0.0 and I suggest to downgrade version.

(node:5227) UnhandledPromiseRejectionWarning: Error: Page crashed!
    at Page._onTargetCrashed (/home/travis/build/munrocket/puppeteer-webgl-ci/node_modules/puppeteer/lib/Page.js:201:28)
    at CDPSession.Page.client.on.event (/home/travis/build/munrocket/puppeteer-webgl-ci/node_modules/puppeteer/lib/Page.js:121:60)
    at CDPSession.emit (events.js:198:13)
    at CDPSession._onMessage (/home/travis/build/munrocket/puppeteer-webgl-ci/node_modules/puppeteer/lib/Connection.js:168:18)
    at Connection._onMessage (/home/travis/build/munrocket/puppeteer-webgl-ci/node_modules/puppeteer/lib/Connection.js:88:25)
    at WebSocketTransport._ws.addEventListener.event (/home/travis/build/munrocket/puppeteer-webgl-ci/node_modules/puppeteer/lib/WebSocketTransport.js:24:32)
    at WebSocket.onMessage (/home/travis/build/munrocket/puppeteer-webgl-ci/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:198:13)
    at Receiver.receiverOnMessage (/home/travis/build/munrocket/puppeteer-webgl-ci/node_modules/ws/lib/websocket.js:800:20)
    at Receiver.emit (events.js:198:13)
(node:5227) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5227) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Steps to reproduce

git clone https://github.com/munrocket/puppeteer-webgl-ci
cd puppeteer-webgl-ci
npm un puppeteer && npm i -D puppeteer@3.0.1 && npm install
CI=2 npm run e2e

@timvandermeij
Copy link

I'm having this problem as well while introducing Puppeteer for Mozilla's PDF.js project in mozilla/pdf.js#11807. It only happens on Windows. I have managed to resolve the "Page crashed!" error by closing all pages explicitly before closing the browser as mentioned in #2269 (comment), so only the "process could not be terminated" error remains. The error does indicate that the browser is closed, so I'm not sure if this error is actually important?!

@munrocket
Copy link
Contributor

In future we can have a problems, because 2.1.1 only with experimental WebGPU renderer.
It's probably my fault in test script, but all was ok in previous version.

@munrocket
Copy link
Contributor

Somehow this problem was fixed in 3.1.0. I am just updated puppeteer in three.js repo and all is ok 😄

@stale
Copy link

stale bot commented Jun 26, 2022

We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

@stale stale bot added the unconfirmed label Jun 26, 2022
@stale
Copy link

stale bot commented Jul 26, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

@stale stale bot closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants