{"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/3600ca084e9c8b5f4174fc5e747f4c52d2100806/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 defined. This means the WebAssembly runtime started loading but the .NET-side updateRootComponents handler has not been registered yet (the runtime is mid-initialization, before callEntryPoint wires up _internal).","triggerScenarios":"Invoking updateWebAssemblyRootComponents during the window between startWebAssembly() resolving startPromise's existence and platform.start()/callEntryPoint() completing — i.e. the runtime is up enough to call but _internal.updateRootComponents is still unregistered.","commonSituations":"Enhanced navigation or hot-reload firing very early in startup; manual calls to the API during boot; a slow initializer blocking callEntryPoint; partial initialization where platform load succeeded but managed code has not registered its callbacks.","solutions":["Let the framework schedule updates via scheduleAfterStarted (await startPromise and the afterStarted callbacks) rather than calling updateRootComponents directly.","Ensure your code runs inside an afterStarted callback so _internal.updateRootComponents is guaranteed registered.","If invoking manually, await Blazor.start() fully before issuing updates.","Check for blocking JS initializers that delay callEntryPoint."],"exampleFix":"// before — calling before runtime registered the callback\nBlazor._internal.updateRootComponents(ops, state); // _internal.updateRootComponents is undefined\n\n// after — wait until afterStarted has run\nBlazor.start().then(() => {\n  // _internal.updateRootComponents is now registered\n  Blazor._internal.updateRootComponents(ops, state);\n});","handlingStrategy":"validation","validationCode":"// Only invoke updateRootComponents once the callback is registered.\nfunction safeUpdateRootComponents(ops, state) {\n  if (typeof Blazor._internal.updateRootComponents !== 'function') return;\n  Blazor._internal.updateRootComponents(ops, state);\n}","typeGuard":"function isUpdateRootComponentsReady() {\n  return typeof Blazor._internal?.updateRootComponents === 'function';\n}","tryCatchPattern":"try {\n  Blazor._internal.updateRootComponents(ops, state);\n} catch (e) {\n  if (/has not initialized/.test(e.message)) {\n    // schedule via afterStarted instead\n  } else throw e;\n}","preventionTips":["Run update logic inside an afterStarted callback.","Await Blazor.start() fully before issuing updates.","Avoid blocking JS initializers that delay callEntryPoint.","Type-check Blazor._internal.updateRootComponents before calling."],"tags":["blazor-webassembly","root-components","lifecycle","initialization"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}