diff --git a/src/native/libs/Common/JavaScript/cross-module/index.ts b/src/native/libs/Common/JavaScript/cross-module/index.ts index 27e4bf51b4e0c4..aa9e2b3f66a2e7 100644 --- a/src/native/libs/Common/JavaScript/cross-module/index.ts +++ b/src/native/libs/Common/JavaScript/cross-module/index.ts @@ -136,9 +136,10 @@ export function dotnetUpdateInternalsSubscriber() { addOnExitListener: table[14], abortStartup: table[15], quitNow: table[16], - normalizeException: table[17], - fetchSatelliteAssemblies: table[18], - fetchLazyAssembly: table[19], + exit: table[17], + normalizeException: table[18], + fetchSatelliteAssemblies: table[19], + fetchLazyAssembly: table[20], }; Object.assign(dotnetLoaderExports, loaderExportsLocal); Object.assign(logger, loggerLocal); diff --git a/src/native/libs/Common/JavaScript/loader/index.ts b/src/native/libs/Common/JavaScript/loader/index.ts index 6230e80c594152..81d4ecddea5c19 100644 --- a/src/native/libs/Common/JavaScript/loader/index.ts +++ b/src/native/libs/Common/JavaScript/loader/index.ts @@ -66,6 +66,7 @@ export function dotnetInitializeModule(): RuntimeAPI { addOnExitListener, abortStartup, quitNow, + exit, normalizeException, fetchSatelliteAssemblies, fetchLazyAssembly, @@ -115,6 +116,7 @@ export function dotnetInitializeModule(): RuntimeAPI { dotnetLoaderExports.addOnExitListener, dotnetLoaderExports.abortStartup, dotnetLoaderExports.quitNow, + dotnetLoaderExports.exit, dotnetLoaderExports.normalizeException, dotnetLoaderExports.fetchSatelliteAssemblies, dotnetLoaderExports.fetchLazyAssembly, diff --git a/src/native/libs/Common/JavaScript/types/exchange.ts b/src/native/libs/Common/JavaScript/types/exchange.ts index 4da02ce6917023..376d33e09bb103 100644 --- a/src/native/libs/Common/JavaScript/types/exchange.ts +++ b/src/native/libs/Common/JavaScript/types/exchange.ts @@ -5,7 +5,7 @@ import type { EmsAmbientSymbolsType } from "../types"; import type { check, error, info, warn, debug, fastCheck, normalizeException } from "../loader/logging"; import type { resolveRunMainPromise, rejectRunMainPromise, getRunMainPromise, abortStartup } from "../loader/run"; -import type { addOnExitListener, isExited, isRuntimeRunning, quitNow } from "../loader/exit"; +import type { addOnExitListener, exit, isExited, isRuntimeRunning, quitNow } from "../loader/exit"; import type { initializeCoreCLR } from "../host/host"; import type { instantiateWasm, installVfsFile, registerDllBytes, loadIcuData, registerPdbBytes, instantiateWebcilModule } from "../host/assets"; @@ -77,6 +77,7 @@ export type LoaderExports = { addOnExitListener: typeof addOnExitListener, abortStartup: typeof abortStartup, quitNow: typeof quitNow, + exit: typeof exit, normalizeException: typeof normalizeException, fetchSatelliteAssemblies: typeof fetchSatelliteAssemblies, fetchLazyAssembly: typeof fetchLazyAssembly, @@ -100,6 +101,7 @@ export type LoaderExportsTable = [ typeof addOnExitListener, typeof abortStartup, typeof quitNow, + typeof exit, typeof normalizeException, typeof fetchSatelliteAssemblies, typeof fetchLazyAssembly, diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts index b7f9dd98ad28a1..1920e54b5a39a2 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts @@ -254,7 +254,11 @@ export class PromiseHolder extends ManagedObject { // so that managed user code running in the continuation could allocate the same GCHandle number and the local registry would be already ok with that completeTask(this.gc_handle, reason, data, this.res_converter); } catch (ex) { - // there is no point to propagate the exception into the unhandled promise rejection + try { + dotnetLoaderExports.exit(1, ex); + } catch { + // there is no point to propagate the exception into the unhandled promise rejection + } } } }