{"record":{"id":"084694a147a6f4df","repo":"jackwener/OpenCLI","slug":"gmail-operation-could-not-start-browser-respons","errorCode":null,"errorMessage":"Gmail ${operation} could not start browser response interception","messagePattern":"Gmail (.+?) could not start browser response interception","errorType":"error_code","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/gmail/utils.js","lineNumber":297,"sourceCode":"    await page.goto(`${GMAIL_ORIGIN}/mail/u/${account}/#inbox`);\n  }\n  for (let attempt = 0; attempt < 60; attempt += 1) {\n    const ready = unwrapBrowserResult(await page.evaluate(`() => !!document.querySelector('input[name=\"q\"]')`), `${operation} readiness probe`);\n    if (ready === true) return;\n    await page.sleep(0.5);\n  }\n  throw new TimeoutError(`Gmail ${operation} page`, 30, 'The Gmail search surface did not become ready. Reload Gmail in the browser and retry.');\n}\n\nasync function installGmailCapture(page, account, endpoint, operation) {\n  if (\n    typeof page?.startNetworkCapture !== 'function'\n    || typeof page?.readNetworkCapture !== 'function'\n  ) {\n    throw new CommandExecutionError(`Gmail ${operation} requires browser response interception`);\n  }\n  if (!await page.startNetworkCapture(`/sync/u/${account}/i/${endpoint}`)) {\n    throw new CommandExecutionError(`Gmail ${operation} could not start browser response interception`);\n  }\n  await page.readNetworkCapture();\n}\n\nasync function waitGmailCaptures(page, endpoint, operation, timeoutSeconds = CAPTURE_WAIT_SECONDS) {\n  const deadline = Date.now() + timeoutSeconds * 1000;\n  let bodylessCaptureObserved = false;\n  // The bridge capture queue is request-oriented: reading it while a response\n  // is still in flight drains that request before its status/body arrive.\n  // Give Gmail's own action time to settle before the first read.\n  await page.sleep(endpoint === 'fd' ? 1 : 3);\n  while (Date.now() < deadline) {\n    const entries = await page.readNetworkCapture();\n    const endpointEntries = (Array.isArray(entries) ? entries : [])\n      .filter((entry) => String(entry?.url || '').includes(`/i/${endpoint}`));\n    if (endpointEntries.some((entry) => (\n      typeof entry?.responsePreview !== 'string'\n      && entry?.responseBodyTruncated !== true","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gmail/utils.js#L279-L315","documentation":"installGmailCapture throws this CommandExecutionError when page.startNetworkCapture exists but returns falsy, meaning the browser failed to arm interception for /sync/u/{account}/i/{endpoint}. The library refuses to continue because subsequent capture reads would silently return nothing.","triggerScenarios":"page.startNetworkCapture('/sync/u/<account>/i/<endpoint>') resolves false: CDP Fetch/Network domain enable failed, the page is in a broken/closed state, or the driver rejected the interception pattern.","commonSituations":"CDP connection dropped mid-session (browser crashed or was closed); Puppeteer/Playwright version where the interception request pattern is rejected; too many concurrent interception handlers; page navigated away between checks.","solutions":["Retry the operation after confirming the browser/page is still open and responsive","Recreate the page (close and reopen) so interception can be re-armed on a fresh target","Update the browser automation driver to a version that supports response interception for the pattern used","Reduce concurrent operations on the same page that may conflict over CDP interception"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (typeof page?.startNetworkCapture !== 'function') throw new Error('capture API unavailable');\nif (!(await page.startNetworkCapture('/sync/u/0/i/s'))) throw new Error('pre-flight interception failed; restart the page');","typeGuard":null,"tryCatchPattern":"try {\n  await fetchThread(page, 0, threadId);\n} catch (e) {\n  if (/could not start browser response interception/.test(e.message)) {\n    page = await reopenPage(browser); // fresh target, re-arm interception\n    await fetchThread(page, 0, threadId);\n  } else throw e;\n}","preventionTips":["Recreate the page after crashes instead of reusing broken targets","Avoid concurrent operations competing for CDP interception on one page","Keep the automation driver updated for interception compatibility"],"tags":["browser-automation","network-capture","gmail","cdp"],"backgroundTag":"network-interception-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}