jackwener/OpenCLI · warning · EmptyResultError

grok export-all

Error message

grok export-all

What it means

EmptyResultError('grok export-all') thrown by readManifest when, after applying offset (and limit) slicing to the manifest rows, no rows remain. It means the manifest was read fine but the requested window is empty.

Source

Thrown at clis/grok/export-all.js:46

  if (maxMs <= 0) return;
  const span = Math.max(0, maxMs - minMs);
  const ms = minMs + Math.floor(Math.random() * (span + 1));
  if (ms > 0) await page.wait(ms / 1000);
}

function readManifest(manifestPath, { offset, limit }) {
  const path = String(manifestPath || '').trim();
  if (!path) return null;
  let parsed;
  try {
    parsed = JSON.parse(fs.readFileSync(path, 'utf8'));
  } catch (error) {
    throw new ArgumentError('manifestPath', `failed to read JSON manifest: ${error?.message || error}`);
  }
  const rows = normalizeManifestRows(parsed);
  const sliced = limit ? rows.slice(offset, offset + limit) : rows.slice(offset);
  if (!sliced.length) {
    throw new EmptyResultError('grok export-all', `No manifest rows after offset=${offset}, limit=${limit}`);
  }
  return sliced;
}

async function collectHistory(page, { offset, limit, maxScrolls }) {
  await page.goto(GROK_URL);
  await page.wait(2);
  const rawResult = await page.evaluate(`(async () => {
    const targetLimit = ${JSON.stringify(limit > 0 ? offset + limit : 0)};
    const maxScrolls = ${JSON.stringify(maxScrolls)};
    const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
    const isVisible = (node) => {
      if (!(node instanceof Element)) return false;
      const style = window.getComputedStyle(node);
      if (style.visibility === 'hidden' || style.display === 'none') return false;
      const rect = node.getBoundingClientRect();
      return rect.width > 0 && rect.height > 0;
    };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Lower the offset or drop it to re-read from the start
  2. Check the manifest row count: rows.length vs your offset/limit
  3. Stop paginating when offset >= total rows instead of calling again
  4. Regenerate the manifest if it is stale/empty

Example fix

// before
cli.exportAll({ manifestPath: 'm.json', offset: 500 }); // manifest has 12 rows
// after
cli.exportAll({ manifestPath: 'm.json', offset: 0, limit: 12 });
Defensive patterns

Strategy: try-catch

Validate before calling

const rows = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
if (offset >= rows.length) throw new Error(`offset ${offset} exceeds manifest rows ${rows.length}`);

Try / catch

try { await cli.exportAll({ manifestPath, offset, limit }); } catch (e) { if (e.name === 'EmptyResultError') return []; throw e; } // treat as end of pagination

Prevention

When it happens

Trigger: clis/grok/export-all.js:46 throws when normalizeManifestRows yields rows but rows.slice(offset, offset+limit) (or rows.slice(offset)) is empty — i.e. offset >= rows.length or the manifest only contains rows that normalize away.

Common situations: Offset past the end of the manifest on the final pagination page; manifest with an empty or malformed rows array; reusing a large offset from a previous, larger manifest.

Related errors


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