{"record":{"id":"b030fd24cc03b8e6","repo":"GoogleChrome/lighthouse","slug":"timespan-already-in-progress","errorCode":null,"errorMessage":"Timespan already in progress","messagePattern":"Timespan already in progress","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/user-flow.js","lineNumber":127,"sourceCode":"  /**\n   * @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) {","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/user-flow.js#L109-L145","documentation":"State-machine guard in UserFlow.navigate(). The UserFlow class enforces that only one gathering operation (navigation or timespan) can be active at a time. navigate() requires both currentTimespan and currentNavigation to be undefined. This throw fires when a timespan is still active — startTimespan() was called but endTimespan() has not completed.","triggerScenarios":"Calling flow.navigate(url) or flow.startNavigation() after flow.startTimespan() without calling flow.endTimespan() first. The currentTimespan property is still set from the prior startTimespan call.","commonSituations":"Forgot to call endTimespan() before navigating. An exception in user interaction code between startTimespan and endTimespan prevented the end call. Using navigate() instead of endTimespan() to close a timespan by mistake.","solutions":["Call flow.endTimespan() before flow.navigate() or flow.startNavigation()","Wrap timespan logic in try/finally to guarantee endTimespan() runs even on error","Check flow.currentTimespan before navigating — if set, end the timespan first"],"exampleFix":"// before — navigate while timespan active\nawait flow.startTimespan();\n// ... interactions ...\nawait flow.navigate(url); // throws\n\n// after — end timespan first\nawait flow.startTimespan();\n// ... interactions ...\nawait flow.endTimespan();\nawait flow.navigate(url);","handlingStrategy":"validation","validationCode":"if (flow.currentTimespan) {\n  await flow.endTimespan();\n}\nawait flow.navigate(url);","typeGuard":"/** @param {UserFlow} flow @returns {boolean} */\nfunction isTimespanActive(flow) {\n  return flow.currentTimespan != null;\n}","tryCatchPattern":"try {\n  await flow.navigate(url);\n} catch (e) {\n  if (e.message === 'Timespan already in progress') {\n    await flow.endTimespan();\n    await flow.navigate(url);\n  } else throw e;\n}","preventionTips":["Always pair startTimespan() with endTimespan() using try/finally","Check flow.currentTimespan before calling navigate or startNavigation","End one gathering operation before starting another"],"tags":["user-flow","state-machine","timespan","navigation"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}