nicolo-ribaudo / modules-import-hooks-refactor

https://nicolo-ribaudo.github.io/modules-import-hooks-refactor/
MIT License
0 stars 0 forks source link

Assertion violated in InnerModuleLinking #2

Closed nicolo-ribaudo closed 2 years ago

nicolo-ribaudo commented 2 years ago

https://nicolo-ribaudo.github.io/modules-import-hooks-refactor/#sec-moduledeclarationlinking

With these three files:

// main
import "a";
import "b";
// a
import("b");
// b

When calling main.Evaluate():

guybedford commented 2 years ago

The evaluating state is always supposed to synchronously transition - that is it should never be observable outside of any one top-level evaluation call.

nicolo-ribaudo commented 2 years ago

The bug with the current spec in this repo is that it calls import("b")->b.Link() synchronously if HostLoadImportedModule returns synchronously, and at that time "b"'s status is evaluating. There hasn't been a promise tick yet since when main.Evaluate() was called.

I can fix this by always waiting a tick before .Link() even if the module was already loaded.

guybedford commented 2 years ago

That sounds correct to me.