Skip to content

Commit ec40bc5

Browse files
authored
Fix regression with instantiateWasm + MODULARIZE (#23579)
We didn't have test coverage of this case and it was broken in #23157. Fixes: #23577
1 parent 7924a23 commit ec40bc5

File tree

62 files changed

+90
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+90
-71
lines changed

src/preamble.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,17 +1015,21 @@ function getWasmImports() {
10151015
// Also pthreads and wasm workers initialize the wasm instance through this
10161016
// path.
10171017
if (Module['instantiateWasm']) {
1018-
try {
1019-
return Module['instantiateWasm'](info, receiveInstance);
1020-
} catch(e) {
1021-
err(`Module.instantiateWasm callback failed with error: ${e}`);
1022-
#if MODULARIZE
1023-
// If instantiation fails, reject the module ready promise.
1024-
readyPromiseReject(e);
1025-
#else
1026-
return false;
1027-
#endif
1028-
}
1018+
return new Promise((resolve, reject) => {
1019+
#if ASSERTIONS
1020+
try {
1021+
#endif
1022+
Module['instantiateWasm'](info, (mod, inst) => {
1023+
receiveInstance(mod, inst);
1024+
resolve(mod.exports);
1025+
});
1026+
#if ASSERTIONS
1027+
} catch(e) {
1028+
err(`Module.instantiateWasm callback failed with error: ${e}`);
1029+
reject(e);
1030+
}
1031+
#endif
1032+
});
10291033
}
10301034
#endif
10311035

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8308
1+
8288
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20171
1+
20132
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8291
1+
8273
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20150
1+
20111
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9309
1+
9289
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
23939
1+
23900
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8252
1+
8231
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20063
1+
20024
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8252
1+
8231

0 commit comments

Comments
 (0)