[browser][coreCLR] running main/exit/abort/logging and infra for unit testing#122646
Merged
pavelsavara merged 14 commits intodotnet:mainfrom Dec 30, 2025
Merged
[browser][coreCLR] running main/exit/abort/logging and infra for unit testing#122646pavelsavara merged 14 commits intodotnet:mainfrom
pavelsavara merged 14 commits intodotnet:mainfrom
Conversation
6b91c6a to
3a18853
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive exit/abort/logging infrastructure for unit testing in browser/CoreCLR environments, enabling better diagnostics and test harness integration.
Key Changes:
- Introduces new test instrumentation via
dotnet.diagnostics.jsmodule with exit handlers, console forwarding, and symbolication skeleton - Breaking API change:
dotnet.run()now keeps the runtime alive; newdotnet.runAndExit()method exits runtime after Main() completes - Adds internal MSBuild properties (
WasmTestSupport,WasmTestExitOnUnhandledError, etc.) to control test behavior and diagnostics deployment
Reviewed changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs | Adds five new boolean properties for test instrumentation flags, gated by version 11.0+ |
| src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonData.cs | Defines the five new test instrumentation properties in boot config JSON schema |
| src/native/libs/System.Native.Browser/utils/index.ts | Replaces exit export with abortTimers and abortPosix for better separation of concerns |
| src/native/libs/System.Native.Browser/utils/host.ts | Removes old exit() function, adds abortTimers() and abortPosix() for cleanup |
| src/native/libs/System.Native.Browser/native/cross-linked.ts | Declares global ABORT and EXITSTATUS variables for emscripten integration |
| src/native/libs/System.Native.Browser/diagnostics/types.ts | New file defining types for marshaling, diagnostics exports, and measured blocks |
| src/native/libs/System.Native.Browser/diagnostics/symbolicate.ts | Skeleton implementation of stack trace symbolication (placeholder for future work) |
| src/native/libs/System.Native.Browser/diagnostics/per-module.ts | Re-exports common per-module definitions for diagnostics |
| src/native/libs/System.Native.Browser/diagnostics/index.ts | Main entry point for diagnostics module initialization |
| src/native/libs/System.Native.Browser/diagnostics/exit.ts | Implements exit handlers, unhandled error handlers, and exit code logging |
| src/native/libs/System.Native.Browser/diagnostics/cross-module.ts | Re-exports common cross-module definitions for diagnostics |
| src/native/libs/System.Native.Browser/diagnostics/console-proxy.ts | Implements console forwarding to WebSocket for test runners |
| src/native/libs/Common/JavaScript/types/public-api.ts | Updates API: removes withConfigSrc() docs, adds run() and runAndExit() with clear behavior distinction |
| src/native/libs/Common/JavaScript/types/internal.ts | Adds DiagnosticsExportsTable to internal exchange, updates asset entry fields, adds OnExitListener type |
| src/native/libs/Common/JavaScript/types/exchange.ts | Adds diagnostics exports, exit lifecycle functions, and additional browser host exports |
| src/native/libs/Common/JavaScript/cross-module/index.ts | Integrates diagnostics exports into cross-module exchange system |
| src/native/libs/Common/JavaScript/CMakeLists.txt | Adds new diagnostics TypeScript source files to build |
| src/native/corehost/browserhost/loader/run.ts | Major refactoring: moves runtime creation logic here, adds createRuntime() and abortStartup(), improved initializeCoreCLR() |
| src/native/corehost/browserhost/loader/lib-initializers.ts | Adds comment clarifying expected function names |
| src/native/corehost/browserhost/loader/index.ts | Registers exit handlers, adds exit-related exports, changes default runtimeId to undefined |
| src/native/corehost/browserhost/loader/host-builder.ts | Implements new run() (keeps runtime alive) and runAndExit() methods, exports loadBootResourceCallback |
| src/native/corehost/browserhost/loader/exit.ts | Complete rewrite with runtimeState, exit listeners, Emscripten integration, proper exit/abort handling |
| src/native/corehost/browserhost/loader/dotnet.d.ts | Updates type definitions for run() and runAndExit() methods, removes withConfigSrc() |
| src/native/corehost/browserhost/loader/config.ts | Renames netLoaderConfig to loaderConfig for consistency |
| src/native/corehost/browserhost/loader/bootstrap.ts | Fixes locateFile() to properly handle query strings for modules vs. assets |
| src/native/corehost/browserhost/loader/assets.ts | Moves runtime creation to run.ts, implements Blazor loadBootResourceCallback support, adds proper cache/integrity handling |
| src/native/corehost/browserhost/libBrowserHost.footer.js | Hides BrowserHost_InitializeCoreCLR and BrowserHost_ExecuteAssembly from Module exports |
| src/native/corehost/browserhost/host/index.ts | Exports getExitStatus and initializeCoreCLR functions |
| src/native/corehost/browserhost/host/host.ts | Implements getExitStatus(), initializeCoreCLR(), improves assembly probing with debug logging, refactors runMain() and runMainAndExit() error handling |
| src/native/corehost/browserhost/host/cross-linked.ts | Declares _BrowserHost_InitializeCoreCLR, _BrowserHost_ExecuteAssembly, and ExitStatus globals |
| src/native/corehost/browserhost/CMakeLists.txt | Removes specific functions from exported list, relying on generic export configuration |
| src/mono/wasm/testassets/WasmBrowserRunMainOnly/wwwroot/main.js | Simplifies to single runAndExit() call instead of manual error handling |
| src/mono/wasm/testassets/WasmBrowserRunMainOnly/WasmBrowserRunMainOnly.csproj | Enables all test instrumentation flags |
| src/mono/wasm/Wasm.Build.Tests/Common/BuildEnvironment.cs | Enables WasmTestSupport for CoreCLR builds |
| src/mono/sample/wasm/Directory.Build.targets | Adds test support properties to nested build |
| src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets | Wires up test instrumentation properties to boot config generation, conditionally includes diagnostics module |
| src/mono/browser/test-main.js | Changes default forwardConsole to only enable on Firefox (not for other browsers in debug mode) |
| eng/testing/tests.browser.targets | Enables WasmTestSupport for CoreCLR library tests |
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/BootJsonData.cs
Outdated
Show resolved
Hide resolved
3 tasks
8383d54 to
d3a2273
Compare
This was referenced Dec 23, 2025
3 tasks
javiercn
approved these changes
Dec 30, 2025
Member
javiercn
left a comment
There was a problem hiding this comment.
Looks good to me. Is it fair to assume that most of the testing is essentially existing tests continue to pass?
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs
Show resolved
Hide resolved
Member
Author
|
/ba-g unrelated failures |
This was referenced Jan 9, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
dotnet.runMainAndExit()anddotnet.runMain()APIs. For Mono too.dotnet.run()to not callexit()and keep runtime alive, only for CoreCLRrunMain()<WasmTestSupport>true</WasmTestSupport>which deploysdotnet.diagnostics.jsdotnet.diagnostics.jsearly when available in the boot configdotnet.diagnostics.jssymbolicateStackTraceexitOnUnhandledErrorappendElementOnExitlogExitCodeasyncFlushOnExitforwardConsoleWasmTestExitOnUnhandledError,WasmTestAppendElementOnExit,WasmTestLogExitCode,WasmTestAsyncFlushOnExit,WasmTestForwardConsoleWasmTestSupportfor library tests and WBT-sEXIT_RUNTIME=1- this enables C++ global destructorsabortStartup(),abortTimers(),abortPosix()isExited(),isRuntimeRunning()LoadBootResourceCallbackfor BlazorModule.onConfigLoadedandModule.onDotnetReadyExitStatustypeabort()/exit()eventslocateFile- for query string propagationBrowserHost_InitializeCoreCLR,BrowserHost_ExecuteAssemblyfrom Module exportsFixes #101169
Fixes #75335
On top of #122616
On top of #122495