Skip to content

Behavior of cyclical dynamic import() is unclear #7472

@yoshi-pi

Description

@yoshi-pi

Hi!

// ./a.js
import('./a.js')

In this cyclical dynamic import example, import('./a.js') executes these algorithms.
Import Calls evaluation -> HostImportModuleDynamically -> fetch an import() module script graph->fetch a single module script.
And, in the fetch a single module script algorithm, the following algorithm is executed since this is a cyclical import and './a.js' has already been fetched.

If moduleMap[(url, moduleType)] exists, asynchronously complete this algorithm with moduleMap[url / moduleType], and return. // step 6

In other words, nothing is fetched and the remaining steps of the algorithm are synchronously run within a same task because the next algorithm is skipped.

run the remaining steps as part of the fetch's process response // step 11

Finally, the fetch the descendants of and link a module script algorithm in the fetch an import() module script graph algorithm is synchronously executed and Link() is performed. The problem is that [[Status]] of a.js is still evaluating, but the Link() algorithm in the ECMAScript spec says

  1. Assert: module.[[Status]] is not linking or evaluating.

I think Link()(and the remaining steps) should be queued as a microtask or a task if [[Status]] of the module is evaluating so that they will be performed after the currently running task is finished.
Did I miss something?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions