{"record":{"id":"64d5842b393e1ffa","repo":"can1357/oh-my-pi","slug":"tab-worker-is-not-initialized","errorCode":null,"errorMessage":"Tab worker is not initialized","messagePattern":"Tab worker is not initialized","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/browser/tab-worker.ts","lineNumber":2200,"sourceCode":"\t\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t\t});\n\t\t}\n\t}\n\n\tasync #close(): Promise<void> {\n\t\tthis.#unsub();\n\t\tthis.#uninstallRejectionGuard();\n\t\tthis.#clearElementCache();\n\t\tconst page = this.#page;\n\t\tif (this.#dialogHandler && page && !page.isClosed()) page.off(\"dialog\", this.#dialogHandler);\n\t\tif (this.#mode === \"headless\" && page && !page.isClosed()) await page.close().catch(() => undefined);\n\t\tif (this.#browser?.connected) this.#browser.disconnect();\n\t\tthis.#transport.send({ type: \"closed\" });\n\t\tthis.#transport.close();\n\t}\n\n\t#requirePage(): Page {\n\t\tif (!this.#page) throw new ToolError(\"Tab worker is not initialized\");\n\t\treturn this.#page;\n\t}\n\n\t#requireBrowser(): Browser {\n\t\tif (!this.#browser) throw new ToolError(\"Tab worker is not initialized\");\n\t\treturn this.#browser;\n\t}\n\n\t#log(level: \"debug\" | \"warn\" | \"error\", msg: string, meta?: Record<string, unknown>): void {\n\t\tthis.#transport.send({ type: \"log\", level, msg, meta });\n\t}\n}\n","sourceCodeStart":2182,"sourceCodeEnd":2213,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/browser/tab-worker.ts#L2182-L2213","documentation":"#requirePage() is the internal guard for all operations that need the worker's Playwright Page. The tab worker process exists but never finished initialization (no page was attached), so any operation requiring the page throws this ToolError instead of dereferencing undefined.","triggerScenarios":"Sending a worker request (navigate, snapshot, observe, act) before the worker's init/connect sequence created the page; the worker was spawned but browser connection failed silently; calling #requirePage-dependent methods after a failed open.","commonSituations":"Race between worker spawn and first command; browser connect failed (missing browser binary, CDP endpoint down) leaving the page unset; worker reused after a crash that skipped re-initialization.","solutions":["Re-open the tab so the worker is fully initialized before issuing commands","Check that the browser could be launched/connected (browser binary installed, CDP URL reachable)","Inspect worker logs sent as { type: 'log' } messages for earlier init failures","Retry the operation after waiting for the worker's ready/initialized signal"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Ensure the worker initialized before sending commands\nawait waitForWorkerReady(worker); // wait for init/'closed'-free state\nif (!pageKnownInitialized(tab)) await reopenTab(name);","typeGuard":null,"tryCatchPattern":"try {\n\tawait send({ type: 'navigate', url });\n} catch (err) {\n\tif (err instanceof ToolError && /not initialized/.test(err.message)) {\n\t\tawait reopenTab(name); // full re-init\n\t\tawait send({ type: 'navigate', url });\n\t} else throw err;\n}","preventionTips":["Wait for worker ready signal before first command","Verify browser binary/CDP endpoint availability at startup","Treat this error as fatal for the tab: reopen rather than retry in place","Monitor worker log messages for init failures"],"tags":["browser","initialization","worker"],"backgroundTag":"worker-not-initialized","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}