@@ -31,6 +31,7 @@ import { preAllocatePThreadWorkerPool, instantiateWasmPThreadWorkerPool } from "
31
31
let config : MonoConfigInternal = undefined as any ;
32
32
let configLoaded = false ;
33
33
let isCustomStartup = false ;
34
+ export const dotnetReady = createPromiseController < any > ( ) ;
34
35
export const afterConfigLoaded = createPromiseController < void > ( ) ;
35
36
export const afterInstantiateWasm = createPromiseController < void > ( ) ;
36
37
export const beforePreInit = createPromiseController < void > ( ) ;
@@ -69,13 +70,17 @@ export function configure_emscripten_startup(module: DotnetModule, exportedAPI:
69
70
// execution order == [5] ==
70
71
module . postRun = [ ( ) => postRunAsync ( userpostRun ) ] ;
71
72
// execution order == [6] ==
72
- module . ready = module . ready . then ( async ( ) => {
73
+
74
+ module . ready . then ( async ( ) => {
73
75
// wait for previous stage
74
76
await afterPostRun . promise ;
75
77
// - here we resolve the promise returned by createDotnetRuntime export
76
- return exportedAPI ;
77
78
// - any code after createDotnetRuntime is executed now
79
+ dotnetReady . promise_control . resolve ( exportedAPI ) ;
80
+ } ) . catch ( err => {
81
+ dotnetReady . promise_control . reject ( err ) ;
78
82
} ) ;
83
+ module . ready = dotnetReady . promise ;
79
84
// execution order == [*] ==
80
85
if ( ! module . onAbort ) {
81
86
module . onAbort = ( ) => mono_on_abort ;
@@ -220,6 +225,7 @@ async function postRunAsync(userpostRun: (() => void)[]) {
220
225
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
221
226
export function abort_startup ( reason : any , should_exit : boolean ) : void {
222
227
if ( runtimeHelpers . diagnosticTracing ) console . trace ( "MONO_WASM: abort_startup" ) ;
228
+ dotnetReady . promise_control . reject ( reason ) ;
223
229
afterInstantiateWasm . promise_control . reject ( reason ) ;
224
230
beforePreInit . promise_control . reject ( reason ) ;
225
231
afterPreInit . promise_control . reject ( reason ) ;
0 commit comments