{"record":{"id":"39cdf7c2ec3b63d9","repo":"can1357/oh-my-pi","slug":"browser-runtime-started-without-an-active-run","errorCode":null,"errorMessage":"Browser runtime started without an active run","messagePattern":"Browser runtime started without an active run","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/browser/tab-worker.ts","lineNumber":1345,"sourceCode":"\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\trejectCancel(abortError);\n\t\t\t\t}\n\t\t\t\t// Cancel in-flight tool calls so user code's awaited proxies reject promptly.\n\t\t\t\tconst toolAbort = timeoutSignal.aborted\n\t\t\t\t\t? postmortem.markExpectedCleanupError(new ToolAbortError(undefined, { cause: timeoutSignal.reason }))\n\t\t\t\t\t: abortError;\n\t\t\t\tfor (const pending of active.pendingTools.values()) {\n\t\t\t\t\tpending.reject(toolAbort);\n\t\t\t\t}\n\t\t\t\tactive.pendingTools.clear();\n\t\t\t};\n\t\t\tif (signal.aborted) onCancel();\n\t\t\telse signal.addEventListener(\"abort\", onCancel, { once: true });\n\t\t\ttry {\n\t\t\t\tconst hooks = this.#hooksForActiveRun();\n\t\t\t\tif (!hooks) throw new ToolError(\"Browser runtime started without an active run\");\n\t\t\t\treturnValue = await withBrowserPromiseCombinatorTracking(\n\t\t\t\t\tactive.rejectionOwner,\n\t\t\t\t\tonFloatingRejection,\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tawait Promise.race([\n\t\t\t\t\t\t\truntime.run(msg.code, `browser-run-${msg.id}.js`, hooks, {\n\t\t\t\t\t\t\t\trunId: msg.id,\n\t\t\t\t\t\t\t\tcwd: msg.session.cwd,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tcancelRejection,\n\t\t\t\t\t\t\tfloatingFailure.promise,\n\t\t\t\t\t\t]),\n\t\t\t\t);\n\t\t\t\tcompleted = true;\n\t\t\t} finally {\n\t\t\t\tsignal.removeEventListener(\"abort\", onCancel);\n\t\t\t}\n\t\t} catch (error) {","sourceCodeStart":1327,"sourceCodeEnd":1363,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/browser/tab-worker.ts#L1327-L1363","documentation":"The browser runtime executes user code through a hooks object obtained from #hooksForActiveRun(); if no active run is registered when the runtime starts, this ToolError is thrown. It signals an internal lifecycle bug: the run cell was not activated (or was already torn down) before the runtime body executed.","triggerScenarios":"Runtime started while the worker had no active run — the run scope was cancelled/torn down before execution, a race between abort and run start, or an internal wiring bug in the worker's run lifecycle.","commonSituations":"Abort signal fired concurrently with run start; nested/reentrant run dispatch; retrying after a cell failure without re-establishing the active run context; version-specific worker lifecycle regressions.","solutions":["Retry the browser-run operation — if transient, a fresh dispatch establishes a new active run","Check whether the run was aborted concurrently (abort signal/timing) and serialize start against teardown","Ensure each runtime execution is initiated through the normal tool-call path that registers the active run","If reproducible, report as a worker lifecycle bug with the sequence of operations"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure a run is active before dispatching\nif (worker.activeRun == null) throw new Error('no active browser run — start a run cell first');","typeGuard":"function hasActiveRun(w: { activeRun: unknown }): boolean {\n  return w.activeRun != null;\n}","tryCatchPattern":"try {\n  returnValue = await runtime.run(code, file, hooks, opts);\n} catch (err) {\n  if (err instanceof ToolError && err.message.includes('without an active run')) {\n    await retryWithBackoff(() => startRunAndExecute(code)); // re-register active run then retry\n  } else throw err;\n}","preventionTips":["Always start runtime execution through the normal tool-call path that registers the active run","Serialize run start against abort/teardown to avoid lifecycle races","Re-establish run state after any cell failure instead of reusing stale context","Treat persistent occurrences as a worker bug and report with repro steps"],"tags":["lifecycle","internal-state","browser-automation","race-condition"],"backgroundTag":"browser-run-not-active","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}