Skip to content

[blazor] Migrate startup callbacks to runtime builder APIs - #69848

Merged
maraf merged 3 commits into
dotnet:mainfrom
maraf:maraf-blazor-startup-callbacks
Nov 6, 2026
Merged

maraf merged 3 commits into
dotnet:mainfrom
maraf:maraf-blazor-startup-callbacks

Conversation

@maraf

@maraf maraf commented Oct 15, 2026

Copy link
Copy Markdown
Member

Migrate Blazor startup callbacks to runtime builder APIs

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Move Blazor lifecycle callbacks onto the runtime host builder.

Description

The runtime migration in dotnet/runtime#134642 moved .NET lifecycle callbacks off Emscripten Module configuration and into loader-owned state. Blazor should register its callbacks through the dedicated builder APIs rather than depend on the runtime's compatibility shim. Dropped config-loaded callbacks leave application-environment accessors and related initialization unavailable.

Register withConfigLoaded and withDownloadResourceProgress directly in createRuntimeInstance, after withModuleConfig and before the application's configureRuntime hook. Keep the remaining Module configuration and use the existing withApplicationEnvironment call for the environment override. Inline the single-use configuration construction and config-loaded callback, and replace the vendored dotnet.d.ts with the Mono runtime declaration snapshot from the runtime PR.

No legacy API fallback is included. This requires runtime builds containing dotnet/runtime#134642 and dotnet/runtime#134498. The currently consumed VMR snapshot in ASP.NET Core main still predates #134642, so the draft should remain blocked on the runtime dependency update and browser startup verification.

Validation

Run after merging origin/main at 8192456de8:

  • Repository root: npm run build -w src/SignalR/clients/ts/signalr -w src/SignalR/clients/ts/signalr-protocol-msgpack - passed.
  • src/Components/Web.JS: npx eslint -c ./src/.eslintrc.js src/Platform/Mono/MonoPlatform.ts - passed.
  • src/Components/Web.JS: npx rollup -c --environment development --forceExit - passed; four debug bundles built.
  • src/Components/Web.JS: npx jest --runInBand - passed; 295 tests across 14 suites.
  • Repository root: git diff --check - passed before committing.

No new tests were added. Browser/E2E startup and red/green regression verification were not run; the JavaScript checks do not establish runtime integration correctness.

Fixes: N/A - no originating ASP.NET Core issue identified; related runtime change linked above.

Note

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

Register config-loaded and download-progress callbacks through the runtime host builder, keeping module-specific options in withModuleConfig. Sync the vendored runtime declarations with the runtime callback migration.

Co-authored-by: Copilot App <[email protected]>
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Oct 15, 2026
@maraf maraf changed the title Migrate Blazor startup callbacks to runtime builder APIs [blazor] Migrate startup callbacks to runtime builder APIs Oct 15, 2026
@maraf maraf self-assigned this Oct 15, 2026
@maraf maraf added the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label Oct 15, 2026
@maraf maraf added this to the 12.0-preview1 milestone Oct 15, 2026
@Youssef1313 Youssef1313 removed this from the 12.0-preview1 milestone Oct 16, 2026
@Youssef1313

Copy link
Copy Markdown
Member

We shouldn't add a preview/RC milestone to PRs manually. That happens via automation after PR gets merged and flows to VMR.

@maraf maraf added this to the 12.0-preview1 milestone Nov 5, 2026
@maraf
maraf marked this pull request as ready for review November 5, 2026 14:44
@maraf
maraf requested a review from a team as a code owner November 5, 2026 14:44
@maraf
maraf requested review from pavelsavara and a balanced review from Copilot November 5, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The consumed runtime reportedly predates the required builder APIs, leaving dependency alignment and real-browser WebAssembly and Auto startup verification unresolved.

No open issues 🎉

What changed in this PR

Moves Blazor WebAssembly startup callbacks from Emscripten Module configuration to runtime host builder APIs, aligning startup with the runtime’s lifecycle callback migration.

Changes:

  • Registers configuration-loaded and download-progress callbacks before the application’s configureRuntime hook.
  • Inlines runtime configuration setup while retaining environment overrides through withApplicationEnvironment.
  • Refreshes the vendored runtime declarations from the linked Mono runtime snapshot.

Runtime dependency updates and browser startup verification remain pending, as noted in the PR description.

File Description
src/​Components/​Web.JS/​src/​Platform/​Mono/​MonoPlatform.ts Moves lifecycle callbacks to builder APIs and inlines configuration setup.
src/​Components/​dotnet-runtime-js/​dotnet.d.ts Updates runtime declarations, including the new callback registration APIs.

Review effort: Balanced

@PureWeen

PureWeen commented Nov 5, 2026

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source-only review of frozen head 0ead91cd2a854244b90e2efce0109d80a9dda26d.

One externally unresolved P2 candidate is noted inline: application configureRuntime code may replace Blazor's withConfigLoaded callback, but the frozen bundle lacks the dotnet/runtime builder implementation needed to establish replace-versus-compose semantics.

Both routed guides completed their in-scope source checks: docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md. Existing feedback was checked; review 5786841721 broadly notes runtime alignment/browser verification, and inline comment 4481955864 requests the latest runtime declaration, but neither establishes or duplicates this callback-semantics candidate. No fresh-feedback check after bundle preparation is claimed.

Execution, tests, CI, browser workflows, samples, and security assessment were excluded by the supplied source-only boundary. No materially changed area was left without a routed guide. Provenance: trusted version-2 bundle, guidance commit 6aacb16a27a677d16278a9814ed04f871020854b, merge base/base tip 6aacb16a27a677d16278a9814ed04f871020854b. Limitations: tracked Git bytes only; runtime implementation and browser execution evidence were unavailable.

Generated by ASP.NET Core Pull Request Review for #69848 · copilot · gpt56 · 150 AIC · ⌖ 18.3 AIC · ⊞ 18.8K
Comment /review to run again

@PureWeen

PureWeen commented Nov 6, 2026

Copy link
Copy Markdown
Member

Copilot's local review panel found no blocking issues at this commit. The open [UNRESOLVED] inline thread on MonoPlatform.ts:176 (#discussion_r4482261777) is for author confirmation only and does not block agent-reviewed-approved.

Use the generated CoreCLR declarations from runtime main CI build 1666566 and update consumers to LoaderConfig.

Co-authored-by: Copilot App <[email protected]>
@maraf maraf removed this from the 12.0-preview1 milestone Nov 6, 2026
@maraf
maraf merged commit 7bf40eb into dotnet:main Nov 6, 2026
32 checks passed
@maraf
maraf temporarily deployed to copilot-pat-pool November 6, 2026 10:39 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 6, 2026 10:39 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 6, 2026 10:40 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 6, 2026 10:42 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 6, 2026 10:43 — with GitHub Actions Inactive
@maraf
maraf temporarily deployed to copilot-pat-pool November 6, 2026 10:44 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

✅ No documentation PR was created.

Confidence that documentation is needed: 8%

No docs needed: internal refactoring of Blazor WebAssembly startup callback registration.

Documentation surfaces considered

  • Conceptual article: Not required — Internal JS startup wiring and vendored runtime typings changed; no user-facing API or documented behavior.
  • Migration guidance: Not required — No action needed by app developers when upgrading.
  • Breaking change: Not required — No concrete compatibility impact for apps; the runtime dependency is a build concern of the repo.

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 235bb233 Deployed Nov 6, 2026 by maraf via conclusion #203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-reviewed-approved area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants