{"record":{"id":"0aac84c8dffcef1a","repo":"dotnet/aspnetcore","slug":"blazor-has-already-started-0aac84","errorCode":null,"errorMessage":"Blazor has already started.","messagePattern":"Blazor has already started\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/Components/Web.JS/src/Boot.Web.ts","lineNumber":39,"sourceCode":"import { hasProgrammaticEnhancedNavigationHandler, performProgrammaticEnhancedNavigation } from './Services/NavigationUtils';\nimport { attachComponentDescriptorHandler, registerAllComponentDescriptors } from './Rendering/DomMerging/DomSync';\nimport { discoverBrowserConfiguration } from './Services/ComponentDescriptorDiscovery';\nimport { JSEventRegistry } from './Services/JSEventRegistry';\nimport { fetchAndInvokeInitializers } from './JSInitializers/JSInitializers.Web';\nimport { ConsoleLogger } from './Platform/Logging/Loggers';\nimport { LogLevel } from './Platform/Logging/Logger';\nimport { resolveOptions, CircuitStartOptions, ReconnectionOptions } from './Platform/Circuits/CircuitStartOptions';\nimport { JSInitializer } from './JSInitializers/JSInitializers';\nimport { enableFocusOnNavigate } from './Rendering/FocusOnNavigate';\nimport { WebAssemblyStartOptions } from './Platform/WebAssemblyStartOptions';\nimport { createBlazorValidation, ensureNovalidateOnForms } from './Validation';\n\nlet started = false;\nlet rootComponentManager: WebRootComponentManager;\n\nfunction boot(options?: Partial<WebStartOptions>) : Promise<void> {\n  if (started) {\n    throw new Error('Blazor has already started.');\n  }\n\n  started = true;\n  options = options || {};\n  options.logLevel ??= LogLevel.Error;\n  Blazor._internal.isBlazorWeb = true;\n\n  // Defined here to avoid inadvertently imported enhanced navigation\n  // related APIs in WebAssembly or Blazor Server contexts.\n  Blazor._internal.hotReloadApplied = () => {\n    if (hasProgrammaticEnhancedNavigationHandler()) {\n      performProgrammaticEnhancedNavigation(location.href, true);\n    }\n  };\n\n  const jsEventRegistry = JSEventRegistry.create(Blazor);\n  rootComponentManager = new WebRootComponentManager(options?.ssr?.circuitInactivityTimeoutMs ?? 2000, jsEventRegistry);\n","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Web.JS/src/Boot.Web.ts#L21-L57","documentation":"Thrown by boot() in Boot.Web.ts when the module-level 'started' flag is already true. Boot.Web.ts is the unified web boot (used by Blazor Web App / blazor.web.js) and must initialize the framework exactly once; a second call would re-create the root component manager and re-run initializers.","triggerScenarios":"Calling Blazor.start() in a Blazor Web App more than once per page load, including via enhanced-navigation or shell code that re-invokes boot.","commonSituations":"Autostart combined with a manual Blazor.start(); a multi-page shell re-running boot on client-side navigation; bundler/HMR re-evaluation of Boot.Web.ts; retry logic that calls boot again after a transient failure that actually succeeded.","solutions":["Invoke Blazor.start() exactly once; rely on autostart OR a single manual call, not both.","Memoize the boot promise at the call site so subsequent attempts reuse it.","Disable autostart when you need programmatic control of timing.","Verify your bundler is not duplicating the boot module under HMR."],"exampleFix":"// before\nif (needsBoot) Blazor.start({ ... }); // called on every navigation -> throws\n\n// after\nlet booted;\nasync function ensureBoot(opts) {\n  if (!booted) booted = Blazor.start(opts);\n  return booted;\n}","handlingStrategy":"validation","validationCode":"// Ensure the unified Web boot runs once.\nlet webBootPromise;\nfunction bootWebOnce(opts) {\n  return webBootPromise ?? (webBootPromise = Blazor.start(opts));\n}","typeGuard":null,"tryCatchPattern":"try {\n  await Blazor.start(opts);\n} catch (e) {\n  if (/already started/.test(e.message)) return;\n  throw e;\n}","preventionTips":["Disable autostart when starting manually.","Centralize boot in the application shell, not in pages.","Guard re-boot attempts in retry/recovery flows.","Verify the boot script is included once in index.html/_Host."],"tags":["blazor-web","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"}