jackwener/OpenCLI · error · CommandExecutionError

Gmail ${operation} capture lost a response body; refusing po

Error message

Gmail ${operation} capture lost a response body; refusing possibly partial results

What it means

waitGmailCaptures throws this CommandExecutionError when the capture window closed with at least one bodyless response observed but no usable matches — a response was seen during the wait, then its body was never recoverable. Like its sibling error, it protects against returning partial Gmail results.

Source

Thrown at clis/gmail/utils.js:346

        typeof entry?.responsePreview !== 'string'
        && entry?.responseBodyTruncated !== true
      ))) {
        bodylessCaptureObserved = true;
      }
      matches.push(...settledEndpointEntries.filter((entry) => (
        typeof entry?.responsePreview === 'string' || entry?.responseBodyTruncated === true
      )));
      if (bodylessCaptureObserved) {
        throw new CommandExecutionError(
          `Gmail ${operation} capture included a response without a body; refusing possibly partial results`,
        );
      }
      return matches.map((entry) => parseJsonCapture(entry, operation));
    }
    await page.sleep(0.25);
  }
  if (bodylessCaptureObserved) {
    throw new CommandExecutionError(
      `Gmail ${operation} capture lost a response body; refusing possibly partial results`,
    );
  }
  throw new TimeoutError(`Gmail ${operation} capture`, timeoutSeconds, `No /${endpoint} response was observed after the Gmail action.`);
}

async function renderedLabels(page, account) {
  await page.goto(`${GMAIL_ORIGIN}/mail/u/${account}/#settings/labels`);
  await page.sleep(2);
  const rows = unwrapBrowserResult(await page.evaluate(`() => {
    const routes = new RegExp('^(?:#(?:inbox|starred|snoozed|sent|drafts|important|spam|trash)|#label/)');
    const systemNames = {
      inbox: 'Inbox', starred: 'Starred', snoozed: 'Snoozed', sent: 'Sent',
      drafts: 'Drafts', important: 'Important', spam: 'Spam', trash: 'Trash',
      scheduled: 'Scheduled', all: 'All Mail',
      'category/purchases': 'Purchases', 'category/social': 'Social',
      'category/updates': 'Updates', 'category/forums': 'Forums',
      'category/promotions': 'Promotions',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry the operation on a stable connection
  2. Check network reliability/proxy stability between browser and Gmail
  3. Update the browser automation driver to one that retains captured response bodies for the full capture window
  4. Reload Gmail before retrying to clear stale capture state
Defensive patterns

Strategy: retry

Try / catch

try {
  const results = await queryThreads(page, 'label:important');
} catch (e) {
  if (/capture lost a response body/.test(e.message)) {
    await page.reload();
    return queryThreads(page, 'label:important');
  }
  throw e;
}

Prevention

When it happens

Trigger: The polling loop in waitGmailCaptures ends (deadline reached) with bodylessCaptureObserved === true and matches still empty for the /{endpoint} capture, after a Gmail action such as a search submission.

Common situations: Response headers arrived but the body read failed before the capture buffer was read; network dropped mid-response; the driver's capture buffer was overwritten; Gmail reloaded mid-operation invalidating captured entries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a1cef845e789cc7e. Report an issue: GitHub.