| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Some clarification on the "other situations" would be nice. After reading this, people might not be clear whether or not their uncaughtException handler can be expected to run or not.
Sorry, something went wrong.
There was a problem hiding this comment.
Well, I think the point is that it is not guaranteed to run for all application 'crashes', where 'crash' is pretty loosely defined. I can send $ kill -9 NODE_PID from the command line to my Node.js process, and the uncaughtException event is never emitted. Granted, there is no exception in this case, but I think that's what the docs are intended to mean. A crash does not necessarily mean uncaughtException is emitted.
How about, "There may be other situations where the application could crash and not trigger this event. For example, receiving a SIGKILL will cause the application to exit abruptly, but an uncaughtException event will not be emitted."?
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe you should just amend the first sentence in the section that describes what 'uncaughtException' event is. Currently it says:
The 'uncaughtException' event is emitted when an exception bubbles all the way back to the event loop.
You could change it to say something like:
The 'uncaughtException' event is emitted when a thrown JavaScript exception bubbles all the way back to the event loop.
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
There was a problem hiding this comment.
I would emphasize this line: **It is not safe to resume normal operation after 'uncaughtException'.**
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
|
@nodejs/documentation |
Sorry, something went wrong.
|
Linking nodejs/docs#82 |
Sorry, something went wrong.
There was a problem hiding this comment.
I think "normal" needs to be defined, otherwise people are likely to interpret as "write the error into a remote mongodb and exit", or something of the like (see #6561). Its not safe to do anything async in the uncaughtException handler ... you can make some sync calls, and then throw the exception or exit.
With console.log being async... I'm not even sure how reasonable calling it is.
/cc @bnoordhuis
Sorry, something went wrong.
There was a problem hiding this comment.
I agree, "normal" is pretty poorly defined here. But I think that's because "normal" can mean different things in different situations for different applications. I agree, however, that being explicit about async operations is probably good. This, and any other "you must not do X" rules would be great. This would allow developers to make their own decisions about fail-fast behavior or not - knowing the tradeoffs.
Sorry, something went wrong.
|
@stevemao that was a fascinating read - thanks for the link. I'm not sure how that discussion should affect this doc change, other than perhaps a little more clarity about things like the async operations being verboten. Maybe that's the way I see it because I'm in the fail-fast camp, and see uncaughtException as being only minimally useful before allowing the app to crash. |
Sorry, something went wrong.
|
I believe most core devs like this approach. So you might want to add some notes about the browser behaviour. A browser always has a "hidden" uncaughtException attached, meaning an uncaught exception will never cause the app to crash, but only exists the current event loop. |
Sorry, something went wrong.
|
Ping... any further thoughts on this? |
Sorry, something went wrong.
|
So we now have
Honestly, I think it's pretty clear, but I will add a final sentence to the docs after, if folks really think it's needed. Maybe something like this?
|
Sorry, something went wrong.
Sorry, something went wrong.
|
Could you merge commits into one. |
Sorry, something went wrong.
State in the documentation that `uncaughtException` is not a reliable way to restart a crashed application, and clarify that an application may crash in ways that do not trigger this event. Use a documented synchronous function in example code. Fixes #6223
|
@JacksonTian done. My editor did a little whitespace cleanup. I hope that's not an issue. |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
State in the documentation that `uncaughtException` is not a reliable way to restart a crashed application, and clarify that an application may crash in ways that do not trigger this event. Use a documented synchronous function in example code. Fixes: #6223 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: #6378
State in the documentation that `uncaughtException` is not a reliable way to restart a crashed application, and clarify that an application may crash in ways that do not trigger this event. Use a documented synchronous function in example code. Fixes: #6223 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: #6378
State in the documentation that `uncaughtException` is not a reliable way to restart a crashed application, and clarify that an application may crash in ways that do not trigger this event. Use a documented synchronous function in example code. Fixes: #6223 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> PR-URL: #6378
| Back | FazBrowse Home | New Git URL |
Checklist
Affected core subsystem(s)
doc
Description of change
State in the documentation that uncaughtException is not a reliable
way to restart a crashed application, and clarify that an application
may crash in ways that do not trigger this event.
Fixes #6223