-
-
Couldn't load subscription status.
- Fork 33.6k
Closed
Description
Version
v23.11.0
Platform
Darwin 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:05 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T8132 arm64
Subsystem
No response
What steps will reproduce the bug?
Files
- package.json:
{"type": "module"} - test.js:
export const one = 1; export const two = await 2; Promise.resolve().then(async () => { console.log({...await import(import.meta.url)}); });
run test.js
How often does it reproduce? Is there a required condition?
100% reproducible
What is the expected behavior? Why is that the expected behavior?
Outputs It works: { one: 1, two: 2 }
the async execution code block inside promise then should be executed normally
What do you see instead?
Warning: Detected unsettled top-level await at file:///path/to/test.js:1
export const one = 1;
And the process exited with error code 13.
Additional information
- It would be related with Top-level await + dynamic import + cyclic import causes "unsettled TLA" error #55468 but they are not the same problem
- Node 22 passes this test (v22.10.0)
- Adding simple noop statement workarounds this problem, this is a modified version which can pass the test
or even
export const one = 1; export const two = await 2; Promise.resolve().then(async () => { console.log('It works:', {...await import(import.meta.url)}); }); void 0; // empty statement do not work
export const one = 1; export const two = await 2; void Promise.resolve().then(async () => { console.log('It works:', {...await import(import.meta.url)}); });
I believed that node runtime incorrectly add await to the last statement, that is totally a mistake
export const one = 1;
export const two = await 2;
await Promise.resolve().then(async () => {
console.log('It works:', {...await import(import.meta.url)});
});Metadata
Metadata
Assignees
Labels
No labels