-
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
Awaiting never-resolved promise makes Deno hang & hot spin. #7945
Comments
I've tried this in latest node and it exits silently with exit code 13.
|
How would Deno know that the promise will never resolve? Shouldn't it just keep the process alive? I would check how browsers handle this, except... they don't have top-level await yet. |
Because no IO ops or timers are going on anymore (ie no timers scheduled to fire, no file reading going on). There is nothing the event loop is waiting for to complete. That means there is no way JS execution will be resumed ever (because there is nothing to trigger that), so the promise can never be resolved. |
Ah yes, it can be determined if the event loop is depleted, and no code is being executed. Guess then it should be safe to error or exit. Also, what about situations like: const temp = () => {};
self.addEventListener(
"message",
temp
);
await new Promise( temp ); Can it be safely determined that the promise will not resolve, as there are still events being listened to? Also, just tested on an older Deno (1.1.0) and it just silently exits with exit code 0. Does this mean that this changed over time? |
deno run
this.It spins because there is nothing happening any more, and tokio can't block the event loop for us (there's nothing to poll).
Deno should either:
UncaughtException
. MaybeAwaitNeverException
or something?The text was updated successfully, but these errors were encountered: