[coreclr] Fix LoadLibraryInitializer test#125176
Open
ilonatommy wants to merge 6 commits intodotnet:mainfrom
Open
[coreclr] Fix LoadLibraryInitializer test#125176ilonatommy wants to merge 6 commits intodotnet:mainfrom
ilonatommy wants to merge 6 commits intodotnet:mainfrom
Conversation
…added AbortStartupOnError_CoreCLR that throws in onRuntimeReady (later lifecycle hook) and checks for the abort message with script name 2. WasmBasicTestApp.lib.module.js — Added throwErrorOnReady param to trigger error in onRuntimeReady (for CoreCLR test) 3. run.ts — Wrapped library initializer calls with try/catch that includes the script name in the error message; extracted shared invokeLibraryInitializers helper 4. BuildTestBase.cs — Added IsCoreClrRuntime helper property to support test separation. 5. BuildWasmAppsJobsListCoreCLR.txt — Added LibraryInitializerTests to CoreCLR CI job list
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/runtime-infrastructure |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes CoreCLR WASM loader behavior so library initializer modules are invoked with the expected arguments and errors during startup correctly trigger abort behavior, and re-enables coverage via a CoreCLR-specific test.
Changes:
- Update loader startup flow to invoke library initializers with the appropriate argument (
loaderConfigforonRuntimeConfigLoaded,dotnetApiforonRuntimeReady) and to callonRuntimeReadyfor modules listed inmodulesAfterConfigLoaded. - Restore startup abort behavior by keying abort logic off
runtimeState.creatingRuntime. - Add/adjust WASM build tests and test assets to validate CoreCLR behavior and re-enable the test in CoreCLR job list.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/native/libs/Common/JavaScript/loader/run.ts | Refactors library initializer invocation and changes onRuntimeReady to receive dotnetApi. |
| src/native/libs/Common/JavaScript/loader/exit.ts | Uses creatingRuntime to decide whether to abort startup on exit. |
| src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/WasmBasicTestApp.lib.module.js | Adds query param to throw from onRuntimeReady to validate abort behavior. |
| src/mono/wasm/Wasm.Build.Tests/LibraryInitializerTests.cs | Splits Mono/CoreCLR coverage and adds CoreCLR-specific abort assertion. |
| src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs | Adds IsCoreClrRuntime helper for conditional test execution. |
| eng/testing/scenarios/BuildWasmAppsJobsListCoreCLR.txt | Re-enables Wasm.Build.Tests.LibraryInitializerTests for CoreCLR scenario runs. |
c6d8572 to
24e2e5c
Compare
88f7bd3 to
d4bf3f2
Compare
…sses loaderConfig for onRuntimeConfigLoaded and dotnetApi for onRuntimeReady (which has getAssemblyExports/getConfig, matching what Mono does) 2. exit.ts: Restored runtimeState.creatingRuntime check (needed because dotnetReady is already true when onRuntimeReady throws) 3. run.ts: Call onRuntimeReady on all library initializers (both modulesAfterConfigLoaded and modulesAfterRuntimeReady), since the SDK only lists lib modules in modulesAfterConfigLoaded 4. run.ts: Wrap library initializer errors with script name in a shared invokeLibraryInitializers helper 5. run.ts: Skip onDotnetReady/onRuntimeReady hooks when downloadOnly is true (runtime is not initialized, so dotnetApi would throw)
d4bf3f2 to
2cee239
Compare
pavelsavara
approved these changes
Mar 4, 2026
maraf
approved these changes
Mar 4, 2026
This was referenced Mar 6, 2026
Open
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 #124899.
The CoreCLR WASM loader had several gaps preventing library initializers from working correctly. This PR fixes the loader and adds a CoreCLR-specific test.
Loader changes (run.ts, exit.ts)
invokeLibraryInitializersnow takes anargsparameter — passesloaderConfigforonRuntimeConfigLoadedanddotnetApiforonRuntimeReady(which hasgetAssemblyExports/getConfig, matching what Mono does)runtimeState.creatingRuntimecheck (needed becausedotnetReadyis already true whenonRuntimeReadythrows)onRuntimeReadyon all library initializers (bothmodulesAfterConfigLoadedandmodulesAfterRuntimeReady), since the SDK only lists lib modules inmodulesAfterConfigLoadedinvokeLibraryInitializershelperTest changes
AbortStartupOnErrorMono-only; addedAbortStartupOnError_CoreCLRthat throws inonRuntimeReadyand checks for the abort message with script namethrowErrorOnReadyquery param support to WasmBasicTestApp.lib.module.jsIsCoreClrRuntimehelper toBuildTestBase.csLibraryInitializerTeststo BuildWasmAppsJobsListCoreCLR.txt to re-enable it