{"record":{"id":"7ec5de0ff684bb4e","repo":"garrytan/gstack","slug":"cdpsessioninvalidated-e-message-cause-playwri","errorCode":null,"errorMessage":"CDPSessionInvalidated: ${e.message}\nCause: Playwright context was recreated (e.g., viewport scale change) and the prior CDP session is stale.\nAction: retry the command; the bridge will create a fresh session.","messagePattern":"CDPSessionInvalidated: (.+?)\nCause: Playwright context was recreated \\(e\\.g\\., viewport scale change\\) and the prior CDP session is stale\\.\nAction: retry the command; the bridge will create a fresh session\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/cdp-bridge.ts","lineNumber":164,"sourceCode":"      : await input.bm.acquireTabLock(input.tabId, CDP_ACQUIRE_TIMEOUT_MS);\n  const acquireMs = Date.now() - acquireStart;\n  logTelemetry({ event: 'cdp_method_lock_acquire_ms', domain: input.domain, method: input.method, ms: acquireMs });\n  logTelemetry({ event: 'cdp_method_called', domain: input.domain, method: input.method, allowed: true, scope: entry.scope });\n\n  try {\n    const page = input.bm.getPageForTab(input.tabId);\n    if (!page) {\n      throw new Error(\n        `Cannot dispatch: tab ${input.tabId} not found.\\n` +\n          'Cause: tab was closed between command queue and dispatch.\\n' +\n          'Action: $B tabs to list current tabs.'\n      );\n    }\n    let session;\n    try {\n      session = await getCdpSession(page);\n    } catch (e: any) {\n      throw new Error(\n        `CDPSessionInvalidated: ${e.message}\\n` +\n          'Cause: Playwright context was recreated (e.g., viewport scale change) and the prior CDP session is stale.\\n' +\n          'Action: retry the command; the bridge will create a fresh session.'\n      );\n    }\n    // Race the call against a hard timeout.\n    const callPromise = session.send(qualified, input.params);\n    const timeoutPromise = new Promise((_, reject) =>\n      setTimeout(() => reject(new Error(`CDPBridgeTimeout: ${qualified} did not return within ${CDP_TIMEOUT_MS}ms`)), CDP_TIMEOUT_MS),\n    );\n    const raw = await Promise.race([callPromise, timeoutPromise]);\n    return { raw, entry };\n  } finally {\n    release();\n  }\n}\n","sourceCodeStart":146,"sourceCodeEnd":181,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/cdp-bridge.ts#L146-L181","documentation":"Error \"CDPSessionInvalidated: ${e.message}\nCause: Playwright context was recreated (e.g., viewport scale change) and the prior CDP session is stale.\nAction: retry the command; the bridge will create a fresh session.\" thrown in garrytan/gstack.","triggerScenarios":"Thrown at browse/src/cdp-bridge.ts:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}