-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Errors thrown by callback swallowed #2
Comments
@zbjornson Thanks for the issue. This is the code I found on MDN: if (typeof window.queueMicrotask !== "function") {
window.queueMicrotask = function (callback) {
Promise.resolve()
.then(callback)
.catch(e => setTimeout(() => { throw e; }));
};
} Can you explain why the exception is thrown in a |
I think it's this difference, from the OP of whatwg/html#512:
https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error With > window.onerror = e => console.log("onerror:", e);
> queueMicrotask(() => { throw new Error("eek"); })
"onerror: Script error."
❌Uncaught Error: eek
> Promise.resolve().then(() => { throw new Error("oops"); }).catch(e => setTimeout(() => { throw e; }))
"onerror: Script error."
❌Uncaught Error: oops
> Promise.resolve().then(() => { throw new Error("oops"); }).catch(e => { throw e; })
// no onerror handler
❌Uncaught (in promise) Error: oops |
Thanks for the explanation. I released a fix for this as 1.1.1 |
Hey there,
Errors thrown by the queued callback will get swallowed, there should be a
catch
on the promise. @domenic corrected this in the polyfill I'd posted on MDN (which was removed for some reason; I just restored it). https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/queueMicrotask#PolyfillThe text was updated successfully, but these errors were encountered: