{"record":{"id":"baa94e24cfe445f2","repo":"GoogleChrome/lighthouse","slug":"navigation-already-in-progress","errorCode":null,"errorMessage":"Navigation already in progress","messagePattern":"Navigation already in progress","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/user-flow.js","lineNumber":128,"sourceCode":"   * @param {LH.Gatherer.GatherResult} gatherResult\n   * @param {LH.UserFlow.StepFlags} [flags]\n   */\n  _addGatherStep(gatherResult, flags) {\n    const gatherStep = {\n      artifacts: gatherResult.artifacts,\n      flags,\n    };\n    this._gatherSteps.push(gatherStep);\n    this._gatherStepRunnerOptions.set(gatherStep, gatherResult.runnerOptions);\n  }\n\n  /**\n   * @param {LH.NavigationRequestor} requestor\n   * @param {LH.UserFlow.StepFlags} [flags]\n   */\n  async navigate(requestor, flags) {\n    if (this.currentTimespan) throw new Error('Timespan already in progress');\n    if (this.currentNavigation) throw new Error('Navigation already in progress');\n\n    const nextFlags = this._getNextNavigationFlags(flags);\n    const gatherResult = await navigationGather(this._page, requestor, {\n      config: this._options?.config,\n      flags: nextFlags,\n    });\n\n    this._addGatherStep(gatherResult, nextFlags);\n  }\n\n  /**\n   * This is an alternative to `navigate()` that can be used to analyze a navigation triggered by user interaction.\n   * For more on user triggered navigations, see https://github.com/GoogleChrome/lighthouse/blob/main/docs/user-flows.md#triggering-a-navigation-via-user-interactions.\n   *\n   * @param {LH.UserFlow.StepFlags} [stepOptions]\n   */\n  async startNavigation(stepOptions) {\n    /** @type {(value: () => void) => void} */","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/user-flow.js#L110-L146","documentation":"State-machine guard in UserFlow.navigate(). navigate() requires currentNavigation to be undefined. This throw fires when a navigation is already in progress — startNavigation() was called but endNavigation() has not completed. Since startNavigation() internally calls navigate(), this also guards against overlapping startNavigation calls.","triggerScenarios":"Calling flow.navigate(url) or flow.startNavigation() after a prior flow.startNavigation() without calling flow.endNavigation() first. The currentNavigation property is still set from the prior startNavigation call.","commonSituations":"Forgot to call endNavigation() after startNavigation(). The user interaction that triggers the navigation was never performed, so endNavigation was never called. Calling navigate() (the synchronous variant) while an async startNavigation flow is pending.","solutions":["Call flow.endNavigation() before starting a new navigation","Ensure the page navigation actually occurs between startNavigation and endNavigation — endNavigation awaits the result","Wrap navigation logic in try/finally to guarantee endNavigation() runs"],"exampleFix":"// before — overlapping navigations\nawait flow.startNavigation();\n// ... user clicks a link triggering navigation ...\nawait flow.startNavigation(); // throws\n\n// after — end first navigation\nawait flow.startNavigation();\n// ... user clicks a link triggering navigation ...\nawait flow.endNavigation();\nawait flow.startNavigation();","handlingStrategy":"validation","validationCode":"if (flow.currentNavigation) {\n  await flow.endNavigation();\n}\nawait flow.navigate(url);","typeGuard":"/** @param {UserFlow} flow @returns {boolean} */\nfunction isNavigationActive(flow) {\n  return flow.currentNavigation != null;\n}","tryCatchPattern":"try {\n  await flow.navigate(url);\n} catch (e) {\n  if (e.message === 'Navigation already in progress') {\n    await flow.endNavigation();\n    await flow.navigate(url);\n  } else throw e;\n}","preventionTips":["Always pair startNavigation() with endNavigation() using try/finally","Ensure the page navigation actually occurs before calling endNavigation","Check flow.currentNavigation before starting a new navigation"],"tags":["user-flow","state-machine","navigation"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}