-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
repl: properly handle uncaughtException #27151
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thinking about the semverness again: it should actually be semver-minor, not major. The reason is that as standalone REPL it only interacts with the user directly and the former behavior was unexpected (it was just ignored). Now it works as it would in an regular application. |
@nodejs/repl PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than one small wording suggestion, this LGTM
@apapirovski you reviewed the older PR, would you mind taking another look? @nodejs/repl this could use some further reviews. |
Landed in c709c52 🎉 |
When running the REPL as standalone program it's now possible to use `process.on('uncaughtException', listener)`. It is going to use those listeners from now on and the regular error output is suppressed. It also fixes the issue that REPL instances started inside of an application would silence all application errors. It is now prohibited to add the exception listener in such REPL instances. Trying to add such listeners throws an `ERR_INVALID_REPL_INPUT` error. PR-URL: nodejs#27151 Fixes: nodejs#19998 Reviewed-By: Lance Ball <[email protected]>
@vsemozhetbyt yes :/ I would like to force-push it out since nothing else landed since but it's quite some time ago. @nodejs/tsc if anyone is around, are you fine with that? |
@BridgeAR If you are somewhat certain that that’s not causing a lot of trouble, I’m okay with it – it’s Sunday & a large holiday after all, and I haven’t seen anything happen that would conflict. But if you want to open a quick revert PR, here’s my 👍 to fast-tracking. |
@addaleax I decided to force-push since I have not seen any activity in any other PR either (besides one that I opened in the meanwhile). I'll fix the PR here and rerun the CI before landing it again. |
### ERR_INVALID_REPL_INPUT | ||
|
||
The input may not be used in the [`REPL`][]. All prohibited inputs are | ||
documented in the [`REPL`][]'s documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Instead of
All prohibited inputs are documented in the [
REPL
][]'s documentation.
maybe this?:
The [
REPL
][] documentation specifies all prohibited inputs.
(Also, does it really?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe this?:
See the [
REPL
][] documentation for more information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it really?
Two things are prohibited in the REPL: uncaughtException
listeners in case the REPL is not running as standalone program and process.setUncaughtExceptionCaptureCallback()
. Both of these cases are documented. I think it's not possible to use some module features but that's just a technical limitation so far.
Is there a better name for EDIT: Oh, and it only affects the interactive REPL, right? |
I personally doubt that this would really confuse anyone since the error message would clarify what it's about and it can only happen for the user of the REPL instance, so it's a direct feedback. I also doubt that it's a problem that the error can only happen when running the REPL inside of another program (it's just not relevant for the standalone REPL). We could go into a different direction as well and use something like |
); | ||
r.close(); | ||
|
||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to use process.on('exit', ...)
instead of setTimeout()
? That will avoid a possible race condition, or if not that, at least the appearance of a possible race condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to verify the timing. Using process.on('exit', ...)
has no timing guarantees.
'});\n' | ||
); | ||
r.write( | ||
'setTimeout(() => {\n' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you go with process.on('exit', ...)
below, maybe this can be setImmediate()
? Not essential. I just like to avoid setTimeout()
in tests wherever possible.
This mostly seems good to me (aside from some minor comments that I left on one of the tests), but I'm wrestling with if we really want to special-case the programmatic use case here. In other words, yes, adding an (Sorry if this has been discussed elsewhere and I just missed it.) Refs: #22112 |
I agree that it will be surprising if this reveals any problems, but just to be thorough.... CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1845/ ✔️ |
Absurd micro-nit: Our commit guidelines say to use an imperative verb as the first word after the subsystem. So instead of "properly handle..." maybe it should be "handle ... properly"? |
When running the REPL as standalone program it's now possible to use `process.on('uncaughtException', listener)`. It is going to use those listeners from now on and the regular error output is suppressed. It also fixes the issue that REPL instances started inside of an application would silence all application errors. It is now prohibited to add the exception listener in such REPL instances. Trying to add such listeners throws an `ERR_INVALID_REPL_INPUT` error. Fixes: nodejs#19998 PR-URL: nodejs#27151 Fixes: nodejs#19998 Reviewed-By: Lance Ball <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Landed in 422e8f7 🎉 |
(Sorry, I just realized I forgot to rerun the CI after the fixup commit) |
When running the REPL as standalone program it's now possible to use `process.on('uncaughtException', listener)`. It is going to use those listeners from now on and the regular error output is suppressed. It also fixes the issue that REPL instances started inside of an application would silence all application errors. It is now prohibited to add the exception listener in such REPL instances. Trying to add such listeners throws an `ERR_INVALID_REPL_INPUT` error. Fixes: #19998 PR-URL: #27151 Fixes: #19998 Reviewed-By: Lance Ball <[email protected]> Reviewed-By: Rich Trott <[email protected]>
Notable changes: * process: * Log errors using `util.inspect` in case of fatal exceptions (Ruben Bridgewater) #27243 * repl: * Add `process.on('uncaughtException')` support (Ruben Bridgewater) #27151 * stream: * Implemented `Readable.from` async iterator utility (Guy Bedford) #27660 * tls: * Expose built-in root certificates (Ben Noordhuis) #26415 * Support `net.Server` options (Luigi Pinca) #27665 * Expose `keylog` event on TLSSocket (Alba Mendez) #27654 * worker: * Added the ability to unshift messages from the `MessagePort` (Anna Henningsen) #27294
Notable changes: * esm: * Added the `--experimental-wasm-modules` flag to support WebAssembly modules (Myles Borins & Guy Bedford) #27659 * process: * Log errors using `util.inspect` in case of fatal exceptions (Ruben Bridgewater) #27243 * repl: * Add `process.on('uncaughtException')` support (Ruben Bridgewater) #27151 * stream: * Implemented `Readable.from` async iterator utility (Guy Bedford) #27660 * tls: * Expose built-in root certificates (Ben Noordhuis) #26415 * Support `net.Server` options (Luigi Pinca) #27665 * Expose `keylog` event on TLSSocket (Alba Mendez) #27654 * worker: * Added the ability to unshift messages from the `MessagePort` (Anna Henningsen) #27294 PR-URL: #27799
Notable changes: * esm: * Added the `--experimental-wasm-modules` flag to support WebAssembly modules (Myles Borins & Guy Bedford) #27659 * process: * Log errors using `util.inspect` in case of fatal exceptions (Ruben Bridgewater) #27243 * repl: * Add `process.on('uncaughtException')` support (Ruben Bridgewater) #27151 * stream: * Implemented `Readable.from` async iterator utility (Guy Bedford) #27660 * tls: * Expose built-in root certificates (Ben Noordhuis) #26415 * Support `net.Server` options (Luigi Pinca) #27665 * Expose `keylog` event on TLSSocket (Alba Mendez) #27654 * worker: * Added the ability to unshift messages from the `MessagePort` (Anna Henningsen) #27294 PR-URL: #27799
When running the REPL as standalone program it's now possible to use
process.on('uncaughtException', listener)
. It is going to use thoselisteners from now on and the regular error output is suppressed.
It also fixes the issue that REPL instances started inside of an
application would silence all application errors. It is now prohibited
to add the exception listener in such REPL instances. Trying to add
such listeners throws an
ERR_INVALID_REPL_INPUT
error.Fixes: #19998
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes