{"record":{"id":"99728fbe2221b09b","repo":"dotnet/aspnetcore","slug":"blazor-webassembly-has-not-initialized","errorCode":null,"errorMessage":"Blazor WebAssembly has not initialized.","messagePattern":"Blazor WebAssembly has not initialized\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Boot.WebAssembly.Common.ts","lineNumber":250,"sourceCode":"  })();\n  return platformLoadPromise;\n}\n\nexport function hasStartedLoadingWebAssemblyPlatform(): boolean {\n  return platformLoadPromise !== undefined;\n}\n\nexport function hasLoadedWebAssemblyPlatform(): boolean {\n  return loadedWebAssemblyPlatform;\n}\n\nexport function updateWebAssemblyRootComponents(operations: string, webAssemblyState: string): void {\n  if (!startPromise) {\n    throw new Error('Blazor WebAssembly has not started.');\n  }\n\n  if (!Blazor._internal.updateRootComponents) {\n    throw new Error('Blazor WebAssembly has not initialized.');\n  }\n\n  if (!started) {\n    scheduleAfterStarted(operations, webAssemblyState);\n  } else {\n    Blazor._internal.updateRootComponents(operations, webAssemblyState);\n  }\n}\n\nasync function scheduleAfterStarted(operations: string, webAssemblyState: string): Promise<void> {\n  await startPromise;\n\n  if (!Blazor._internal.updateRootComponents) {\n    throw new Error('Blazor WebAssembly has not initialized.');\n  }\n\n  Blazor._internal.updateRootComponents(operations, webAssemblyState);\n}","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Boot.WebAssembly.Common.ts#L232-L268","documentation":"Thrown by updateWebAssemblyRootComponents when startPromise exists but Blazor._internal.updateRootComponents is not yet assigned. That hook is installed midway through startCore (Boot.WebAssembly.Common.ts:167), so calling the update API before startCore reaches that line finds the function undefined.","triggerScenarios":"Invoking updateWebAssemblyRootComponents while startCore is still in flight (e.g. during platform load, before the updateRootComponents hook is wired up), but after startWebAssembly has set startPromise.","commonSituations":"A root-component update fired during the WebAssembly boot window; navigation or render-mode switching that pushes updates before the runtime hooked up the interop; tests that call update immediately after start() without awaiting.","solutions":["Await startPromise (i.e. await Blazor.start()) before issuing root-component updates, so startCore has finished wiring hooks.","Type-guard the call: if (typeof Blazor._internal.updateRootComponents === 'function') { ... } before invoking."],"exampleFix":"// before: update races the boot body\nBlazor.start();\nBlazor._internal.updateRootComponents(ops, state); // _internal.updateRootComponents undefined -> throws\n\n// after\nawait Blazor.start();\nif (typeof Blazor._internal.updateRootComponents === 'function') {\n  Blazor._internal.updateRootComponents(ops, state);\n}","handlingStrategy":"type-guard","validationCode":"function isUpdateHookReady(): boolean {\n  return typeof (Blazor as any)._internal?.updateRootComponents === 'function';\n}\n\nif (isUpdateHookReady()) {\n  Blazor._internal.updateRootComponents(ops, state);\n} else {\n  console.warn('WebAssembly boot not yet initialized; deferring update.');\n}","typeGuard":"function hasUpdateRootComponents(b: any): b is { _internal: { updateRootComponents: (ops: string, state: string) => void } } {\n  return typeof b?._internal?.updateRootComponents === 'function';\n}","tryCatchPattern":"try {\n  Blazor._internal.updateRootComponents(ops, state);\n} catch (e) {\n  if (/has not initialized/.test((e as Error).message)) {\n    await Blazor.start();\n    Blazor._internal.updateRootComponents(ops, state);\n  } else throw e;\n}","preventionTips":["Await Blazor.start() before calling root-component update APIs.","Type-guard the _internal.updateRootComponents function before invoking.","Treat a missing hook as 'boot incomplete' and defer.","Do not call update from initializers that run mid-boot."],"tags":["blazor-webassembly","root-components","startup","race-condition"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}