{"record":{"id":"415ea2555cfccf3d","repo":"jackwener/OpenCLI","slug":"gmail-operation-capture","errorCode":null,"errorMessage":"Gmail ${operation} capture","messagePattern":"Gmail (.+?) capture","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"clis/gmail/utils.js","lineNumber":350,"sourceCode":"      }\n      matches.push(...settledEndpointEntries.filter((entry) => (\n        typeof entry?.responsePreview === 'string' || entry?.responseBodyTruncated === true\n      )));\n      if (bodylessCaptureObserved) {\n        throw new CommandExecutionError(\n          `Gmail ${operation} capture included a response without a body; refusing possibly partial results`,\n        );\n      }\n      return matches.map((entry) => parseJsonCapture(entry, operation));\n    }\n    await page.sleep(0.25);\n  }\n  if (bodylessCaptureObserved) {\n    throw new CommandExecutionError(\n      `Gmail ${operation} capture lost a response body; refusing possibly partial results`,\n    );\n  }\n  throw new TimeoutError(`Gmail ${operation} capture`, timeoutSeconds, `No /${endpoint} response was observed after the Gmail action.`);\n}\n\nasync function renderedLabels(page, account) {\n  await page.goto(`${GMAIL_ORIGIN}/mail/u/${account}/#settings/labels`);\n  await page.sleep(2);\n  const rows = unwrapBrowserResult(await page.evaluate(`() => {\n    const routes = new RegExp('^(?:#(?:inbox|starred|snoozed|sent|drafts|important|spam|trash)|#label/)');\n    const systemNames = {\n      inbox: 'Inbox', starred: 'Starred', snoozed: 'Snoozed', sent: 'Sent',\n      drafts: 'Drafts', important: 'Important', spam: 'Spam', trash: 'Trash',\n      scheduled: 'Scheduled', all: 'All Mail',\n      'category/purchases': 'Purchases', 'category/social': 'Social',\n      'category/updates': 'Updates', 'category/forums': 'Forums',\n      'category/promotions': 'Promotions',\n    };\n    const seen = new Set();\n    const result = [];\n    const add = (id, name, type, unreadCount = null) => {","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gmail/utils.js#L332-L368","documentation":"waitGmailCaptures throws this TimeoutError when no /{endpoint} response was observed at all within timeoutSeconds (default CAPTURE_WAIT_SECONDS) after the Gmail action. The capture never saw a matching /sync request/response, so there is nothing to parse.","triggerScenarios":"Calling queryThreads/fetchThread where after submitSearch (or the action) no /sync/u/N/i/{endpoint} entry appears in page.readNetworkCapture() before the deadline.","commonSituations":"Gmail served results from cache without a network /sync call; the search submission didn't actually trigger a sync (Enter key not dispatched natively); request URL pattern changed after a Gmail UI update; extremely slow network exceeding the capture timeout.","solutions":["Retry the query; transient timing issues are the most common cause","Confirm the action actually fired (search box contained the query, Enter was pressed) — see the 'requires native browser input' errors otherwise","Increase CAPTURE_WAIT_SECONDS for slow networks","Check whether Gmail's UI/update changed the /sync/i/{endpoint} URL pattern and update the endpoint constant","Reload Gmail and retry to clear any stale page state"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// confirm the action fires a sync call before waiting on captures\nconst q = await page.evaluate('() => document.querySelector(\"input[name=q]\")?.value || \"\"');\nif (!q) throw new Error('search query never set; /sync will not be triggered');","typeGuard":null,"tryCatchPattern":"try {\n  const threads = await queryThreads(page, 'from:boss@corp.com');\n} catch (e) {\n  if (e instanceof TimeoutError && /capture/.test(e.message)) {\n    await page.sleep(3);\n    return queryThreads(page, 'from:boss@corp.com'); // retry with longer capture window\n  }\n  throw e;\n}","preventionTips":["Increase CAPTURE_WAIT_SECONDS on slow networks","Confirm the search actually submitted (Enter pressed natively, query set)","Update endpoint constants if Gmail changes its /sync/i/{endpoint} URLs","Reload Gmail and retry when no sync response is observed"],"tags":["timeout","network-capture","gmail","browser-automation"],"backgroundTag":"page-load-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}