Skip to content

Commit

Permalink
Module['onRuntimeInitializeFailed'] (#5357)
Browse files Browse the repository at this point in the history
  • Loading branch information
buu700 committed Jul 3, 2017
1 parent f6d1438 commit 8030e3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/postamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ Module['exit'] = Module.exit = exit;
var abortDecorators = [];

function abort(what) {
if (Module['onRuntimeInitializeFailed']) {
setTimeout(function () { Module['onRuntimeInitializeFailed'](what); }, 0);
}

#if USE_PTHREADS
if (ENVIRONMENT_IS_PTHREAD) console.error('Pthread aborting at ' + new Error().stack);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -2324,7 +2324,7 @@ function integrateWasmJS(Module) {
receiveInstance(output['instance']);
}).catch(function(reason) {
Module['printErr']('failed to asynchronously prepare wasm: ' + reason);
Module['quit'](1, reason);
abort(reason);
});
return {}; // no exports yet; we'll fill them in later
#else
Expand Down Expand Up @@ -2509,7 +2509,7 @@ function integrateWasmJS(Module) {
} else if (curr === 'interpret-asm2wasm' || curr === 'interpret-s-expr' || curr === 'interpret-binary') {
if (exports = doWasmPolyfill(global, env, providedBuffer, curr)) break;
} else {
throw 'bad method: ' + curr;
abort('bad method: ' + curr);
}
}

Expand Down

0 comments on commit 8030e3b

Please sign in to comment.