-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
does not work with dynamic await import()
#7649
Comments
Hey @MylesBorins - can you take a look at this issue? How are TLA and dynamic imports meant to interact? Should this example work? Thanks :-) |
I can confirm that one should be able to await a dynamic import, that was one of the motivating use cases in the original proposal (although not to be abused, please still use static import too!) I can confirm that the same code, with slight modifications, works in node.js v14.12.0 |
Yeah, I don't think it is TLA. As @TooTallNate mentions, the module isn't ready when the promise is resolved even using the |
The issue refers to the TLA in the imported module, I'm pretty sure. The dynamic import promise resolves prematurely when the imported module's execution hits the TLA for the timeout. This might be reproducible with static imports... Also, it seems it's only reproduced by awaiting a new macrotask or more 😕 |
Ah yeah, I see... The real bug is, dynamically importing a module which has TLA fails (which is exactly what the title says 😱 ). So it feels like we are resolving promises out of order then. |
I think this is the same: |
Me and @piscisaureus investigated the issue and arrive at the conclusion that |
Should this be re-opened considering that #7672 was reverted? |
Running:
Seems like the
import()
function is not properly waiting for the module to become resolved, so there is nodefault
property on the object returned fromimport()
.Initially reported in: vercel-community/deno#40
The text was updated successfully, but these errors were encountered: