{"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Web.JS/src/Boot.Web.ts#L21-L57","documentation":"Thrown by boot() in Boot.Web.ts (the blazor.web.js entry, used by Blazor Web App SSR + interactive) when its module-level 'started' flag is already true. blazor.web.js is single-shot: it sets up streaming render, enhanced navigation, form validation, and the root component manager in one pass.","triggerScenarios":"Calling Blazor.start() twice on a Blazor Web App page; autostart firing together with a manual start; a JS initializer that calls Blazor.start().","commonSituations":"Including <script src=\"blazor.web.js\" autostart> plus a manual Blazor.start({...}); a navigation/HMR cycle re-evaluating the bundle; a custom layout that re-includes the script tag.","solutions":["Choose either autostart or a single manual Blazor.start(), not both.","Guard the call with a window-level started flag before invoking.","Ensure blazor.web.js is included exactly once per full page load (enhanced navigation does not re-include scripts, but full reloads / iframes might)."],"exampleFix":"// before\n<script src=\"blazor.web.js\" autostart></script>\n<script>Blazor.start();</script> <!-- throws -->\n\n// after\n<script src=\"blazor.web.js\"></script>\n<script>Blazor.start();</script>","handlingStrategy":"validation","validationCode":"function startWebBlazorOnce(opts?: any) {\n  if ((window as any).__blazorWebStarted) return Promise.resolve();\n  (window as any).__blazorWebStarted = true;\n  return Blazor.start(opts);\n}","typeGuard":"function isWebBlazorStarted(): boolean {\n  return !!(window as any).__blazorWebStarted;\n}","tryCatchPattern":"try {\n  await Blazor.start(opts);\n} catch (e) {\n  if (/already started/.test((e as Error).message)) return;\n  throw e;\n}","preventionTips":["Use autostart OR one manual start; not both.","Include blazor.web.js exactly once per full page load.","Guard the manual start with a window flag.","Ensure enhanced navigation does not re-evaluate the boot bundle."],"tags":["blazor-web","startup","singleton","autostart"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}