{"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Boot.WebAssembly.Common.ts#L43-L79","documentation":"Thrown by setWebAssemblyOptions when the module-level 'options' variable is already set. WebAssembly options are configured once during boot; a second call indicates the WebAssembly platform was asked to configure twice.","triggerScenarios":"Calling Blazor.start({ webAssembly: {...} }) twice, or Boot.Web.ts calling setWebAssemblyOptions while Boot.WebAssembly.ts has already configured it, or an initializer re-invoking the configuration.","commonSituations":"Hosting a Blazor WebAssembly app under a Blazor Web App shell where both bundles call into WebAssembly config; manual start plus autostart; HMR re-running the WebAssembly boot module.","solutions":["Start WebAssembly exactly once; guard the call site before configuring.","If hosting WebAssembly inside Web, let the Web boot path configure WebAssembly options and do not call Blazor.start() again for the WebAssembly bundle.","Disable autostart on blazor.webassembly.js when starting manually."],"exampleFix":"// before\nBlazor.start({ webAssembly: { ... } });\nBlazor.start({ webAssembly: { ... } }); // throws\n\n// after\nif (!window.__wasmConfigured) {\n  window.__wasmConfigured = true;\n  Blazor.start({ webAssembly: { ... } });\n}","handlingStrategy":"validation","validationCode":"function configureWasmOnce(opts: Partial<WebAssemblyStartOptions>) {\n  if ((window as any).__wasmOptionsConfigured) return;\n  (window as any).__wasmOptionsConfigured = true;\n  Blazor.start({ webAssembly: opts });\n}","typeGuard":"function wasmOptionsConfigured(): boolean {\n  return !!(window as any).__wasmOptionsConfigured;\n}","tryCatchPattern":"try {\n  Blazor.start({ webAssembly: opts });\n} catch (e) {\n  if (/already been configured/.test((e as Error).message)) return;\n  throw e;\n}","preventionTips":["Start WebAssembly once; let the Web boot path configure it when hosted inside Web.","Disable autostart on blazor.webassembly.js when starting manually.","Track configuration with a window flag.","Do not re-configure options from initializers."],"tags":["blazor-webassembly","startup","configuration","singleton"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}