Open mhassan1 opened 1 year ago
im also facing the same issue.
I can confirm the symptom. The roor cause seems like at https://github.com/thomasdondorf/puppeteer-cluster/blob/b5b098aed84b8d2c170b3f9d0ac050f53582df45/src/Cluster.ts#L238, the 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
at Worker.
delete --single-process
run ok
It is possible that puppeteer-cluster relies on multiple processes of browser instances.
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: https://github.com/thomasdondorf/puppeteer-cluster/issues/323