{"record":{"id":"0c2c5245013fc57f","repo":"dotnet/aspnetcore","slug":"webassembly-options-have-already-been-configured","errorCode":null,"errorMessage":"WebAssembly options have already been configured.","messagePattern":"WebAssembly options have already been configured\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Boot.WebAssembly.Common.ts","lineNumber":61,"sourceCode":"  firstUpdate = false;\n}\n\nlet resolveInitializersPromise: (value: void) => void;\nconst initializersPromise = new Promise<void>(resolve => {\n  resolveInitializersPromise = resolve;\n});\n\nexport function isFirstUpdate() {\n  return firstUpdate;\n}\n\nexport function setWaitForRootComponents(): void {\n  waitForRootComponents = true;\n}\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","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Web.JS/src/Boot.WebAssembly.Common.ts#L43-L79","documentation":"Thrown by setWebAssemblyOptions in Boot.WebAssembly.Common when the module-level 'options' is already set. The WebAssembly options resolution is meant to run once per boot; calling it again would overwrite resolved WebAssemblyStartOptions and desynchronize initializer handling.","triggerScenarios":"The WebAssembly boot path (Boot.WebAssembly.ts) being entered twice in the same page, or setWebAssemblyOptions invoked manually after the framework already configured options.","commonSituations":"Autostart plus a manual Blazor.start() in WebAssembly mode; a host page that includes blazor.webassembly.js twice; HMR re-running the boot module; micro-frontend setups that mount multiple WebAssembly apps through one boot path.","solutions":["Boot WebAssembly exactly once per page; remove the duplicate call.","Disable autostart and start manually from a single location.","Memoize the start promise so re-entry is idempotent.","Confirm the boot script is included only once in the host HTML."],"exampleFix":"// before\n<script autostart src=\"_framework/blazor.webassembly.js\"></script>\n<button onclick=\"Blazor.start()\">Restart</button> // throws\n\n// after\n<script src=\"_framework/blazor.webassembly.js\" autostart=\"false\"></script>\n<button onclick=\"bootOnce()\">Start</button>\n<script>let p; function bootOnce(){ return p ?? (p = Blazor.start()); }</script>","handlingStrategy":"validation","validationCode":"// Memoize WebAssembly boot so options are configured once.\nlet wasmPromise;\nfunction bootWasmOnce(opts) {\n  return wasmPromise ?? (wasmPromise = Blazor.start(opts));\n}","typeGuard":null,"tryCatchPattern":"try {\n  await Blazor.start(opts);\n} catch (e) {\n  if (/already been configured|already started/.test(e.message)) return;\n  throw e;\n}","preventionTips":["Include blazor.webassembly.js exactly once in the host HTML.","Use a single guarded boot function.","Disable autostart when calling Blazor.start() yourself.","Audit HMR/bundler for duplicate boot module evaluation."],"tags":["blazor-webassembly","boot","lifecycle","double-start"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}