{"record":{"id":"387ebf91bd374f2d","repo":"dotnet/aspnetcore","slug":"blazor-webassembly-has-already-started","errorCode":null,"errorMessage":"Blazor WebAssembly has already started.","messagePattern":"Blazor WebAssembly has already started\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Boot.WebAssembly.Common.ts","lineNumber":75,"sourceCode":"}\n\nexport function setWebAssemblyOptions(initializersReady: Promise<Partial<WebAssemblyStartOptions>>) {\n  if (options) {\n    throw new Error('WebAssembly options have already been configured.');\n  }\n  setOptions(initializersReady);\n\n\n  async function setOptions(initializers: Promise<Partial<WebAssemblyStartOptions>>) {\n    const configuredOptions = await initializers;\n    options = configuredOptions;\n    resolveInitializersPromise();\n  }\n}\n\nexport function startWebAssembly(components: RootComponentManager<WebAssemblyComponentDescriptor>, options: WebAssemblyServerOptions | undefined): Promise<void> {\n  if (startPromise !== undefined) {\n    throw new Error('Blazor WebAssembly has already started.');\n  }\n\n  startPromise = new Promise(startCore.bind(null, components, options));\n\n  return startPromise;\n}\n\nasync function startCore(components: RootComponentManager<WebAssemblyComponentDescriptor>, options: WebAssemblyServerOptions | undefined, resolve, _) {\n  if (inAuthRedirectIframe()) {\n    // eslint-disable-next-line @typescript-eslint/no-empty-function\n    await new Promise(() => { }); // See inAuthRedirectIframe for explanation\n  }\n\n  const platformLoadPromise = loadWebAssemblyPlatformIfNotStarted(options);\n\n  addDispatchEventMiddleware((browserRendererId, eventHandlerId, continuation) => {\n    // It's extremely unusual, but an event can be raised while we're in the middle of synchronously applying a\n    // renderbatch. For example, a renderbatch might mutate the DOM in such a way as to cause an <input> to lose","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Boot.WebAssembly.Common.ts#L57-L93","documentation":"Thrown by startWebAssembly when the module-level startPromise is already defined. startWebAssembly loads the Mono runtime and entry point exactly once; a second call indicates the WebAssembly platform was asked to boot twice.","triggerScenarios":"Calling Blazor.start() twice for a WebAssembly app, or two boot paths both invoking startWebAssembly (e.g. Blazor Web App with an InteractiveWebAssembly render mode plus a manual start).","commonSituations":"Autostart plus manual start; HMR reloading blazor.webassembly.js; tests or hosting shells that re-invoke boot; an iframe re-running the bundle.","solutions":["Guard with hasStartedWebAssembly() (Boot.WebAssembly.Common.ts:200) before starting.","Pick autostart OR a single manual Blazor.start(); not both.","Ensure the WebAssembly bundle is loaded once per page/iframe."],"exampleFix":"// before\nBlazor.start();\n// ... later ...\nBlazor.start(); // throws\n\n// after\nimport { hasStartedWebAssembly } from './Boot.WebAssembly.Common';\nif (!hasStartedWebAssembly()) {\n  await Blazor.start();\n}","handlingStrategy":"validation","validationCode":"import { hasStartedWebAssembly } from './Boot.WebAssembly.Common';\n\nfunction startWasmOnce(components: any, opts: any) {\n  if (hasStartedWebAssembly()) return Promise.resolve();\n  return startWebAssembly(components, opts);\n}","typeGuard":"import { hasStartedWebAssembly } from './Boot.WebAssembly.Common';\n\nfunction wasmStarted(): boolean {\n  return hasStartedWebAssembly();\n}","tryCatchPattern":"try {\n  await Blazor.start();\n} catch (e) {\n  if (/already started/.test((e as Error).message)) return;\n  throw e;\n}","preventionTips":["Guard start with hasStartedWebAssembly().","Pick autostart OR one manual start.","Load blazor.webassembly.js once per page/iframe.","Avoid HMR re-evaluation of the boot module."],"tags":["blazor-webassembly","startup","singleton","autostart"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}