Skip to content

[browser] Move .NET callbacks off Module - #134642

Merged
maraf merged 5 commits into
dotnet:mainfrom
maraf:maraf/migrate-module-extensions
Oct 2, 2026
Merged

maraf merged 5 commits into
dotnet:mainfrom
maraf:maraf/migrate-module-extensions

Conversation

@maraf

@maraf maraf commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Move .NET lifecycle and download-progress callbacks out of Emscripten's Module so the loader owns its own callback state. withConfigLoaded replaces the legacy module configuration callback; withDotnetReady remains available internally without becoming part of the public host-builder declaration.

CoreCLR now accepts both function and array forms for preInit and preRun, avoiding the startup failure caused by spreading a function callback. Mono follows the same loader-owned callback model, and the browser test asset uses the new builder API.

Follow up on #134498
Resolves #132555

Note

This PR description was generated with the assistance of GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@maraf maraf added arch-wasm WebAssembly architecture os-browser Browser variant of arch-wasm labels Sep 25, 2026
@maraf maraf added this to the 12.0.0 milestone Sep 25, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
maraf and others added 2 commits September 30, 2026 14:03
Blazor (dotnet/aspnetcore) still passes onConfigLoaded, onDotnetReady and
onDownloadResourceProgress inside the object handed to withModuleConfig.
After moving those callbacks to loader-owned state they were silently
dropped, which broke Blazor WASM startup.

Add extractLegacyModuleCallbacks to both the CoreCLR and Mono loaders.
It routes the three legacy callbacks into loaderCallbacks and returns a
copy of the config without them, so nothing lands on Module. The helper
is non-mutating and returns the input unchanged when no legacy callback
is present (including when withModuleConfig is called with no argument).

Also migrate the in-repo call sites (test-main.mjs, browser-advanced and
browser-shutdown samples) to the new builder methods, so the shim only
serves external callers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@maraf
maraf marked this pull request as ready for review October 1, 2026 08:13
@maraf

maraf commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

/ba-g Failure is #135031

@maraf
maraf merged commit 9f1b439 into dotnet:main Oct 2, 2026
135 of 137 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[browser][coreclr] TypeError: (Module.preRun || []) is not iterable

2 participants