You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The important code is in the file test.js. This file is run both in the context of the main window and in a worker:
var inWorker = typeof window === "undefined";
var context = inWorker ? self : window;
if (inWorker) {
self.importScripts("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.4.1/bluebird.js");
console.log("worker running");
}
context.addEventListener("unhandledrejection", function() {
console.log("Unahndled rejection detected by custom handler!", inWorker);
});
Promise.reject(new Error("X"));
Expected behavior
The console should show these lines:
Unahndled rejection detected by custom handler! false
worker running
Unahndled rejection detected by custom handler! true
The first one unhandled rejection is from the main window. The 2nd is from the worker. Bluebird does produce warnings but those are not the issue here.
Actual behavior
Unahndled rejection detected by custom handler! false
worker running
The unhandled rejection in the worker is never detected by the handler.
Observations
On Chrome, removing Bluebird from the worker produces the expected behavior.
Also, assigning to self.onunhandledrejection works fine.
I believe the issue is with fireDomEvent. document is not available in a worker, so the fallback is used.
fireDomEvent should be modified to create events using new Event, which is available in workers.
The text was updated successfully, but these errors were encountered:
lextiz
added a commit
to lextiz/bluebird
that referenced
this issue
Aug 8, 2016
Versions
Bluebird: 3.4.1. I don't know if it happens with earlier versions but I suspect it does.
Browsers: Chrome 51, Firefox 46. AFAIK, this would be reproducible on all platforms that support workers.
Reproducing the case
Run this plunker, and observe the console output.
The important code is in the file
test.js
. This file is run both in the context of the main window and in a worker:Expected behavior
The console should show these lines:
The first one unhandled rejection is from the main window. The 2nd is from the worker. Bluebird does produce warnings but those are not the issue here.
Actual behavior
The unhandled rejection in the worker is never detected by the handler.
Observations
On Chrome, removing Bluebird from the worker produces the expected behavior.
Also, assigning to
self.onunhandledrejection
works fine.I believe the issue is with
fireDomEvent
.document
is not available in a worker, so the fallback is used.fireDomEvent
should be modified to create events usingnew Event
, which is available in workers.The text was updated successfully, but these errors were encountered: