-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Promise.reject() crashes repl when using --unhandled-rejections=strict #35232
Comments
FWIW, this bug is not a regression. It happens in Node 12 as well. I'm curious to take a crack at this, but I have no idea where to begin. Can anyone suggest a starting point? (How do repl tests work…?) |
Should repl ignore the flag as use warn |
Setting it to none would silence such issues in the REPL and the main issue is the programmatic REPL instances. If these are started and we just set the flag to none, rejections in the "regular code" are also silenced. Otherwise it's a good solution (if set to warn). |
That would fix the crash, but it would be a little noisy.
I feel like I'd want to make the repl set an Is there a good place I could add code like that? |
with throw mode, it should bubble up as an uncaught exception, the same way throwing does. |
@devsnek yeah I'm a bit surprised with the behavior here honestly. I won't have time to look into it during the week but might have some time during the weekend. |
The reason why rejections behave differently is that we use domains to track uncaught exceptions in the REPL. |
Didn't had time to look into it over the weekend, and I'm not sure if I'll have time to look into it during the week, so if anyone else wants to take a look go ahead. As a workaround we should probably let it to warn, and then keep this issue open to investigate making it work without changing the default. |
With the new defaults added in v15, this issue is especially pertinent. |
This is quite the blast from the past, I haven't touched domains in several years ^^ I will take a look. |
So the issue appears to be that process.on('unhandledRejection', (e, p) => {
p.catch((e) => {
if (process.domain === self._domain) {
self._domain.emit('error', e);
}
});
}); Wouldn't work. I think we'd have to parse the stack trace which sucks but I don't really see an alternative, that wouldn't work with Also we should probablyt refactor the REPL to not use domains 🤷 |
Ok so the issue is:
Rather than fix domains: I think the REPL needs to set a (separate) Edit: Actually I'll attempt a more general fix first |
This comment has been minimized.
This comment has been minimized.
Talking to Anna, she suggested emitting the ereor on the domain if |
This should be fixed in the next version. |
is this fixed? I'm still seeing this on windows 10 with node v15.6.0 behavior is the same with and without flag
|
Running a file isn't an issue since it's supposed to error and stop (that's the whole point of the flag). What might be considered an issue (although I'm not sure if this is very important) is that |
I'm getting this in current lts 16.14.0 what would be the 'next version' your referring too ? |
(i do not get this in v14.17.0) |
I have also reproduced this in Node 12.18.4.
What steps will reproduce the bug?
Launch the repl with this command:
(
--unhandled-rejections=throw
has the same issue.)On the repl command line, type
Promise.reject()
.What is the expected behavior?
When an uncaught error is thrown in the repl, the repl should print "Uncaught error" without terminating the process. For example:
What do you see instead?
The process crashes.
Additional information
This bug will become more important in Node 15 when
--unhandled-rejections=throw
becomes the default, per PR #33021. At that point, the bug will repro when launchingnode
using the default settings with no flags.The text was updated successfully, but these errors were encountered: