-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Top-level await incorrectly awaits promise continuation in REPL #43777
Comments
@guybedford FYI |
@tniessen the repl top-level await doesn't use v8 directly and instead runs through an emulation layer. Short of someone to do the work to refactor that hack, this is a bug in the emulation layer originally implemented I believe by Gus. The transform is here - https://github.com/nodejs/node/blob/main/lib/internal/repl/await.js, and the tests for the rewriting are here - https://github.com/nodejs/node/blob/main/test/parallel/test-repl-preprocess-top-level-await.js. I would suggest adding the failing line to the transform tests to debug further what it is actually executing and why it is giving the wrong result. Working out the failing test would be a good start. |
Thank you for the info @guybedford! I might be missing something but the transform seems to always wrap the code in an node/lib/internal/repl/await.js Lines 155 to 156 in 90bc773
The REPL then seems to Lines 571 to 575 in a055337
Line 602 in a055337
Lines 617 to 621 in a055337
In this case, the value that the REPL should evaluate to is a
I'm not sure what I'd expect the transform to produce. Maybe something like |
I think the solution is to rewrite all |
Fixes: nodejs#43777 PR-URL: nodejs#43827 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Fixes: nodejs/node#43777 PR-URL: nodejs/node#43827 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Version
18.5.0
Platform
Linux 5.13.0-Ubuntu x86_64 x86_64 x86_64 GNU/Linux
Subsystem
repl
What steps will reproduce the bug?
In REPL:
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
Note that
typeof
prints'object'
, which is correct and matchesPromise { ... }
.What do you see instead?
Note that
typeof
prints'object'
, which is correct, but the value of the expression is shown to be123
in the REPL, which is a'number'
.Additional information
Chrome and Edge seem to handle this as I'd expect. Firefox seems to handle this like Node.js (so I'm assuming it's a bug).
The text was updated successfully, but these errors were encountered: