Skip to content

[[CycleRoot]] is expected on all evaluated modules, but it's not set on modules that throw synchronously #3582

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

Open
nicolo-ribaudo opened this issue May 1, 2025 · 1 comment · May be fixed by #3583

Comments

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented May 1, 2025

Test case:

// entrypoint.js
await import("./foo.js").catch(() => {});
await import("./foo.js");
// foo.js
throw 1;

When we call module.Evaluate() for the first dynamic import:

  • Step 8 of Evaluate() calls InnerModuleEvaluation(module)
  • Step 13.a of InnerModuleEvaluation does ? module.ExecuteModule()
    • module.ExecuteModule() returns an abrupt completion, so we return early without going to step 16.b.viii (which is the only place in the spec that sets module.[[CycleRoot]])
  • Step 9 of Evaluate sets module.[[Status]] to ~evaluated~ and module.[[EvaluationError]] to the throw completion.

When we call module.Evaluate() for the second dynamic import:

  • Step 3 of Evaluate() does "If module.[[Status]] is either ~evaluating-async~ or ~evaluated~, set module to module.[[CycleRoot]]".
  • [[CycleRoot]] was never set on module, so it's ~empty~.
  • Step for tries to read [[TopLevelCapability]] from it, which doesn't make sense because it's not a module record.

Step-by-step debugger for the first import: https://nicolo-ribaudo.github.io/es-module-evaluation/#s=QQo%3D&c=&a=Cg%3D%3D&f=QQ%3D%3D

@nicolo-ribaudo
Copy link
Member Author

Oh well, this is the same as #2823

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant