-
Notifications
You must be signed in to change notification settings - Fork 312
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
Bug: No way to handle UnhandledPromiseRejectionWarning
inside cluster.work
#502
Comments
im also facing the same issue. |
I can confirm the symptom. The roor cause seems like at puppeteer-cluster/src/Cluster.ts Line 238 in b5b098a
SetTimeout made Cluster.doWork run in the event loop scheduled as macro tasks. Therefore, any error rejects Cluster.doWork does not populate to Cluster.work and onward, which leads to the unhandeld rejection warning.
|
me too |
throw new Error('Unable to get browser page'); Error: Unable to get browser page |
delete --single-process |
When the
Promise
returned bydoWork
here is rejected, we end up with anUnhandledPromiseRejectionWarning
, which we can only deal with using a globalprocess.on('unhandledRejection', ...)
listener. There should be a better way for consumers to handle this error; maybecluster
should emit aclustererror
event (or anerror
event, since it may be fatal), in this case.I would be happy to contribute a fix, once we have an approach.
To reproduce:
NOTE: This reproduces on my Mac because the
--single-process
flag prevents Chromium from starting up. YMMV.Actual output:
An
UnhandledPromiseRejectionWarning
is emitted by the process, and the process exits:Expected output:
An event is emitted by
cluster
, and noUnhandledPromiseRejectionWarning
is emitted by the processRelated: #323
The text was updated successfully, but these errors were encountered: