Skip to content

Commit 87042c1

Browse files
committed
[dylink] Use an async iife to loadAsync loadWebAssemblyModule
Split from emscripten-core#23619 emscripten-core#23619
1 parent 081ebf2 commit 87042c1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/lib/libdylink.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -871,13 +871,14 @@ var LibraryDylink = {
871871
}
872872

873873
if (flags.loadAsync) {
874-
if (binary instanceof WebAssembly.Module) {
875-
var instance = new WebAssembly.Instance(binary, info);
876-
return Promise.resolve(postInstantiation(binary, instance));
877-
}
878-
return WebAssembly.instantiate(binary, info).then(
879-
(result) => postInstantiation(result.module, result.instance)
880-
);
874+
return (async function() {
875+
if (binary instanceof WebAssembly.Module) {
876+
var instance = new WebAssembly.Instance(binary, info);
877+
return postInstantiation(binary, instance);
878+
}
879+
const result = await WebAssembly.instantiate(binary, info);
880+
return postInstantiation(result.module, result.instance);
881+
})();
881882
}
882883

883884
var module = binary instanceof WebAssembly.Module ? binary : new WebAssembly.Module(binary);

0 commit comments

Comments
 (0)