[browser] Align CLR completeTaskWrapper to exit on exception, matching Mono#127314
Merged
pavelsavara merged 3 commits intodotnet:mainfrom Apr 24, 2026
Merged
Conversation
…o behavior Fixes dotnet#125587 The CLR implementation of completeTaskWrapper silently swallowed exceptions during Promise-to-Task marshalling, while the Mono implementation called mono_exit(1, ex) to terminate the runtime. This aligns the CLR side by calling dotnetLoaderExports.exit(1, ex), which normalizes the error, notifies exit listeners, tears down timers, and then quits. Also adds exit() to the LoaderExports cross-module interface so it can be called from the interop module.
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns the CoreCLR browser runtime’s Promise→Task marshalling error path with Mono by exiting the runtime when completeTaskWrapper throws, preventing permanently-hung managed Tasks and corrupted interop state.
Changes:
- Added
exitto the loader exports shape (LoaderExports) and its cross-module exchange table. - Wired
exitthrough loader serialization (loaderExportsToTable) and cross-module deserialization (loaderExportsFromTable). - Updated
PromiseHolder.completeTaskWrapperto calldotnetLoaderExports.exit(1, ex)when marshalling throws.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshaled-types.ts | Calls loader exit() when Promise→Task completion marshalling throws. |
| src/native/libs/Common/JavaScript/types/exchange.ts | Extends LoaderExports/LoaderExportsTable to include exit. |
| src/native/libs/Common/JavaScript/loader/index.ts | Adds exit to the loader exports object and serialization table. |
| src/native/libs/Common/JavaScript/cross-module/index.ts | Updates deserialization indices to include exit from the table. |
Comments suppressed due to low confidence (1)
src/native/libs/Common/JavaScript/loader/index.ts:123
loaderExportsToTable()currently inserts the newexitentry beforenormalizeException, which changes the numeric indices of all subsequent slots. Since this table is used as a cross-bundle ABI, new exports should be appended to the end to keep existing indices stable; moveexitto the end of the returned array and adjustloaderExportsFromTable()accordingly.
dotnetLoaderExports.addOnExitListener,
dotnetLoaderExports.abortStartup,
dotnetLoaderExports.quitNow,
dotnetLoaderExports.exit,
dotnetLoaderExports.normalizeException,
dotnetLoaderExports.fetchSatelliteAssemblies,
dotnetLoaderExports.fetchLazyAssembly,
];
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was referenced Apr 23, 2026
Open
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
This was referenced Apr 24, 2026
maraf
approved these changes
Apr 24, 2026
Member
maraf
left a comment
There was a problem hiding this comment.
Looks good to me and my copilot 👍
Member
Author
|
/ba-g unrelated failures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #125587
Summary
The CLR implementation of
completeTaskWrappersilently swallowed exceptions during Promise-to-Task marshalling, while the Mono implementation calledmono_exit(1, ex)to terminate the runtime. An exception here means the managedTaskwill never complete (hanging forever) and the GCHandle/proxy state is corrupted.This PR aligns the CLR side by calling
dotnetLoaderExports.exit(1, ex), which normalizes the error, notifies exit listeners, tears down timers, and then quits — matching the Mono behavior.Changes
exittoLoaderExportstype andLoaderExportsTableexitto the loader functions object and serialization tableexitat the new table indexcompleteTaskWrappercatch block now callsexit(1, ex)instead of silently swallowing