Dynamic import hangs if thread default main context != global default main context
System information
What is your operating system and version? Fedora 39
What is your version of GJS? 1.78.0-2.fc39
Bug information
Steps to reproduce
# cat main.js
const { GLib } = imports.gi;
function import_sync(mod) {
let result;
let exception;
const ctx = GLib.MainContext.new();
const loop = GLib.MainLoop.new(ctx, true);
ctx?.push_thread_default();
try {
import(mod).then(res => {
result = res;
}).catch(ex => {
exception = ex;
logError(ex);
}).finally(() => {
loop.quit();
});
printerr('run');
loop.run();
printerr('done');
} finally {
ctx?.pop_thread_default();
}
if (exception)
throw exception;
return result;
}
import_sync('./aux.js').run();
# cat aux.js
export function run() {
printerr('Success!!!');
}
Current behaviour
# gjs main.js
run
and hangs.
Expected behaviour
After const ctx = GLib.MainContext.new();
replaced with const ctx = null;
in main.js
:
# gjs main.js
run
done
Success!!!