Skip to content

Commit c912890

Browse files
one more aborted promise (#78764)
Co-authored-by: pavelsavara <[email protected]>
1 parent 175a49e commit c912890

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/mono/wasm/runtime/startup.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { preAllocatePThreadWorkerPool, instantiateWasmPThreadWorkerPool } from "
3131
let config: MonoConfigInternal = undefined as any;
3232
let configLoaded = false;
3333
let isCustomStartup = false;
34+
export const dotnetReady = createPromiseController<any>();
3435
export const afterConfigLoaded = createPromiseController<void>();
3536
export const afterInstantiateWasm = createPromiseController<void>();
3637
export const beforePreInit = createPromiseController<void>();
@@ -69,13 +70,17 @@ export function configure_emscripten_startup(module: DotnetModule, exportedAPI:
6970
// execution order == [5] ==
7071
module.postRun = [() => postRunAsync(userpostRun)];
7172
// execution order == [6] ==
72-
module.ready = module.ready.then(async () => {
73+
74+
module.ready.then(async () => {
7375
// wait for previous stage
7476
await afterPostRun.promise;
7577
// - here we resolve the promise returned by createDotnetRuntime export
76-
return exportedAPI;
7778
// - any code after createDotnetRuntime is executed now
79+
dotnetReady.promise_control.resolve(exportedAPI);
80+
}).catch(err => {
81+
dotnetReady.promise_control.reject(err);
7882
});
83+
module.ready = dotnetReady.promise;
7984
// execution order == [*] ==
8085
if (!module.onAbort) {
8186
module.onAbort = () => mono_on_abort;
@@ -220,6 +225,7 @@ async function postRunAsync(userpostRun: (() => void)[]) {
220225
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
221226
export function abort_startup(reason: any, should_exit: boolean): void {
222227
if (runtimeHelpers.diagnosticTracing) console.trace("MONO_WASM: abort_startup");
228+
dotnetReady.promise_control.reject(reason);
223229
afterInstantiateWasm.promise_control.reject(reason);
224230
beforePreInit.promise_control.reject(reason);
225231
afterPreInit.promise_control.reject(reason);

0 commit comments

Comments
 (0)