Skip to content

[CORRUPTED] Synthetic Benchmark PR #64536 - Allow JS root components to reinitialize on circuit restart#72

Open
ofir-frd wants to merge 2 commits intobase_pr_64536_20260121_4023from
corrupted_pr_64536_20260121_4023
Open

[CORRUPTED] Synthetic Benchmark PR #64536 - Allow JS root components to reinitialize on circuit restart#72
ofir-frd wants to merge 2 commits intobase_pr_64536_20260121_4023from
corrupted_pr_64536_20260121_4023

Conversation

@ofir-frd
Copy link

Benchmark PR dotnet#64536

Type: Corrupted (contains bugs)

Original PR Title: Allow JS root components to reinitialize on circuit restart
Original PR Description: Fixes dotnet#64523.

Tests cleanup:

This PR reverts changes to tests architecture done in dotnet#64159 to avoid fixing multiple issues in one PR. It removes the additional test file and moves PersistentStateIsSupportedInDynamicJSRoots to PersistentState-connected test file.

Framework fixes:

The goal of the changes is to differentiate between the following scenarios:

Multi-Host / Different Renderer Types (Unsupported - Throws Error)

  1. Host A initializes: A Server-rendered Blazor application starts
  2. Circuit A connects: Server renderer (e.g., rendererId = 0)
  3. .NET calls enableJSRootComponents: With Server's rendererId and managerInstance
  4. JS state: manager is set, currentRendererId = 0
  5. Host B attempts initialization: On the same page, a WebAssembly Blazor host is also loaded
  6. WASM renderer calls enableJSRootComponents: With WebAssembly's rendererId (e.g., 1) and its own managerInstance.
  7. Exception thrown: "Dynamic root components have already been enabled."
  8. Developer responsibility: It's up to the developer to ensure only one host enables dynamic root components.

Same Renderer Type Circuit Restart (Supported)

  1. Initial state (after 1st iteration): Circuit 1 was previously connected and then shut down
  2. JS state: manager variable holds the old DotNetObjectReference from Circuit 1. currentRendererId holds the renderer ID (e.g., Server renderer = 0)
  3. Circuit 2 connects: A new Blazor Server circuit is created (same renderer type - Server)
  4. .NET calls enableJSRootComponents: The framework calls this with:
  • Same rendererId] (e.g., 0 for Server)
  • New managerInstance (a fresh DotNetObjectReference from Circuit 2)
  1. No exception thrown: the new managerInstance replaces the old stale one
  2. JS initializers skipped: hasInitializedJsComponents is already true, so initializers don't run again.
  3. Circuit 2 becomes interactive: Components can now use Blazor.rootComponents.add() with the new valid manager.
    Original PR URL: Allow JS root components to reinitialize on circuit restart dotnet/aspnetcore#64536

Compliance Violation

  • Rule: Use Curly Braces for All Control Flow Statements
  • Language: TypeScript
  • File: src/Components/Web.JS/src/Rendering/JSRootComponents.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants