-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
window.reportError(e)? #13484
Comments
Looking at mdn it appears that this API is only available in Worker context. |
It isn't. It's also available in workers. |
Yes if you look at the spec it's exposed in both cases. (I am not sure if adding it is the thing to do - we decided not to implement this API (yet) in Node.js and the suggestion to add it stalled) |
Okay, this seems useful. I'm in favor of adding this API. If anyone is interested in working on a PR, let me know, we'll try to provide some pointers. |
I've been working on this. It seems everything
@benjamingr Do I have this correct with respect to what the Node behaviour would be + process termination? |
You do, though I still haven't merged the Node.js PR since I am still not 100% sure this is a good API. Also "The error is printed to the console in the format of an exception." - this likely won't happen if there is an errorMonitor or uncaughtException handler so the user can redirect these to monitoring. |
Perfect, yeah I meant that to be conditioned under the unhandled case as well since browsers already do that with Looking at nodejs/node#41912 it looks like we reached the same conclusion to crash by throwing on the next tick. One difference however is that by elevating the error for the first time at the next tick means it won't be printed synchronously like it is in browsers. I avoided this by splitting the error into two, the input error is printed immediately while a generic error is thrown next tick to cause the crash:console.log(1);
reportError(new Error("foo"));
console.log(2); Probably wouldn't be as palatable if we didn't already have this kind of formatting for child worker errors:// temp.ts
new Worker(new URL("temp2.ts", import.meta.url).href, { type: "module" });
// temp2.ts
throw new Error("foo"); |
What do you think should happen in terms of developer experience when someone does We are discussing either warning in Node.js (a non-error causes a warning with a stack trace), always logging the stack trace when |
@benjamingr Maybe Node should tie it to
|
Will be released in Deno 1.21.0 |
The web platform supports
self.reportError(e)
to trigger an uncaught error with semantics similar tosetTimeout(() => { throw e; })
.Would it make sense for Deno to implement this API?
The text was updated successfully, but these errors were encountered: