Fix race condition in dynamic module resolution.
Previously the module could resolve while we were awaiting the source load and cause an import error.
I wasn't able to reproduce this behavior in our test suite but it definitely shows up with binary gjs
.
// a.js
import("./b.js")
.then((b) => {
b.Z();
})
.catch((err) => logError(err));
import("./b.js")
.then((b) => {
b.Y();
})
.catch((err) => logError(err));
imports.mainloop.run();
// b.js
export function Z() {
log('bee bee');
}
export function Y() {
log('bae bae');
}
gjs a.js
Current Behavior:
JS ERROR: Error: Unevaluated or errored module returned by module resolve hook
run@resource:///org/gnome/gjs/modules/script/mainloop.js:19:22
@examples/a.js:13:18