{"record":{"id":"b3d3e2318e291fd0","repo":"dotnet/aspnetcore","slug":"unexpected-renderer-id-rendererid-encountered","errorCode":null,"errorMessage":"Unexpected renderer ID '${rendererId}' encountered while discovering new state.","messagePattern":"Unexpected renderer ID '(.+?)' encountered while discovering new state\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Services/WebRootComponentManager.ts","lineNumber":324,"sourceCode":"          // and if there are no updates on this batch, push an empty set of operations\n          // to ensure we send the state over. Same for wasm below.\n          serverState = discoverServerPersistedState(document) || '';\n          if (serverState && serverState !== '') {\n            const ops = operationsByRendererId.get(WebRendererId.Server);\n            if (!ops) {\n              operationsByRendererId.set(WebRendererId.Server, []);\n            }\n          }\n        } else if (rendererId === WebRendererId.WebAssembly) {\n          webAssemblyState = discoverWebAssemblyPersistedState(document) || '';\n          if (webAssemblyState && webAssemblyState !== '') {\n            const ops = operationsByRendererId.get(WebRendererId.WebAssembly);\n            if (!ops) {\n              operationsByRendererId.set(WebRendererId.WebAssembly, []);\n            }\n          }\n        } else {\n          throw new Error(`Unexpected renderer ID '${rendererId}' encountered while discovering new state.`);\n        }\n      }\n    }\n\n    for (const [rendererId, operations] of operationsByRendererId) {\n      const batch: RootComponentOperationBatch = {\n        batchId: this._nextOperationBatchId++,\n        operations,\n      };\n      this._pendingOperationBatches[batch.batchId] = batch;\n      const batchJson = JSON.stringify(batch);\n\n      if (rendererId === WebRendererId.Server) {\n        updateServerRootComponents(batchJson, serverState);\n      } else {\n        this.updateWebAssemblyRootComponents(batchJson, webAssemblyState);\n      }\n    }","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Services/WebRootComponentManager.ts#L306-L342","documentation":"Thrown in refreshRootComponents() at WebRootComponentManager.ts:324 while iterating rendererIds collected from persisted-state discovery. The loop only knows how to discover state for WebRendererId.Server and WebRendererId.WebAssembly; any other numeric rendererId means the enum gained a value the JS client does not understand, so it refuses rather than silently dropping persisted state for unknown renderers.","triggerScenarios":"A component's assignedRendererId is set to a value outside {Server, WebAssembly} (per the WebRendererId enum known to this JS client), and discoverNewState=true. The else branch of the Server/WebAssembly check fires.","commonSituations":"Version skew between the .NET server runtime (which may assign a new renderer enum value) and the shipped blazor.web.js (which only knows the old enum). Mixing a newer server build with an older cached/published JS bundle. Custom rendermode registrations that produce renderer IDs outside the known set.","solutions":["Clear cached browser assets and republish so blazor.web.js matches the server runtime version exactly.","Ensure the JS bundle is rebuilt whenever the server-side Blazor runtime is updated (run npm run build / publish the client assets together).","If you added a custom rendermode, verify it maps to a known WebRendererId rather than an arbitrary integer.","Check for stale CDN-cached blazor.web.js and bust the cache."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { WebRendererId } from '../Rendering/WebRendererId';\nfunction isKnownRendererId(id: number): boolean {\n  return id === WebRendererId.Server || id === WebRendererId.WebAssembly;\n}","typeGuard":"function isKnownWebRendererId(id: unknown): id is WebRendererId {\n  return id === WebRendererId.Server || id === WebRendererId.WebAssembly;\n}","tryCatchPattern":null,"preventionTips":["Always rebuild and republish blazor.web.js alongside server runtime updates.","Bust CDN/browser cache of the JS bundle after upgrades.","Map custom rendermodes only to known WebRendererId values.","Run integration tests that assert Server/WebAssembly state discovery works across upgrades."],"tags":["blazor","renderer","version-mismatch","rendermode","cache"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}