Skip to content

Top-level await + dynamic import + cyclic import causes "unsettled TLA" error #55468

@guyutongxue

Description

@guyutongxue

Version

v22.10.0

Platform

Linux GuyuDebian 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Create following files:

  • package.json:
{
  "private": true,
  "type": "module"
}
  • foo.js:
const bar = await import("./bar.js");
console.log(bar.default);
  • bar.js:
import {} from "./foo.js";
export default "It works!";

Then run node foo.js.

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior? Why is that the expected behavior?

Outputs It works!.

import {} from "./foo.js" doesn't import anything, and foo.js has already been linked, so it should not block the evaluation of bar.js.

What do you see instead?

Warning: Detected unsettled top-level await at file:///home/guyutongxue/Downloads/temp/web/foo.js:1
const bar = await import("./bar.js");

And the process exited with error code 13.

Additional information

Behavior of other runtime:

  • Deno produces same result (error on unsettled TLA).
  • Chromium: stuck on dynamic import.
  • Firefox: also stuck on dynamic import.
  • WinterJS: dynamic import promise rejected with internal error.
  • Safari: outputs It works! successfully.
  • Bun: outputs It works! successfully.

I'm not sure what is the correct behavior that ECMAScript specification defines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions