jackwener/OpenCLI · error · CommandExecutionError

`Failed to capture GeoGebra screenshot: ${err?.message || er

Error message

`Failed to capture GeoGebra screenshot: ${err?.message || err}`

What it means

CommandExecutionError thrown when page.screenshot() fails while capturing the GeoGebra canvas for the hexagon demo. The original error's message is embedded so the underlying capture failure (browser, file write, or session issue) is visible.

Source

Thrown at clis/geogebra/hexagon.js:52

      ['V4', `(-${size},0)`],
      ['V5', `(${size}*cos(4*pi/3),${size}*sin(4*pi/3))`],
      ['V6', `(${size}*cos(5*pi/3),${size}*sin(5*pi/3))`],
    ];
    for (const [name, coords] of vertices) {
      const result = requireGgbSuccess(await ggbEval(page, `${name}=${coords}`), `Failed to create point ${name}`);
      results.push({ step: `${name}=${coords}`, result: `ok (${result.label || name})` });
    }

    const polygon = requireGgbSuccess(await ggbEval(page, 'Hexagon=Polygon(V1,V2,V3,V4,V5,V6)'), 'Failed to create hexagon polygon');
    results.push({ step: 'Hexagon=Polygon(V1,V2,V3,V4,V5,V6)', result: `ok (${polygon.label || 'hexagon created'})` });

    const objectCount = await ggbWaitForObjectCount(page, 7);
    const objects = await ggbListObjects(page);
    const screenshotPath = path.join(os.tmpdir(), 'opencli-geogebra-hexagon.png');
    try {
      await page.screenshot({ path: screenshotPath });
    } catch (err) {
      throw new CommandExecutionError(`Failed to capture GeoGebra screenshot: ${err?.message || err}`);
    }

    if (Array.isArray(objects) && objects.length > 0) {
      results.push({ step: `canvas has ${objectCount} objects`, result: objects.map(o => `${o.name}(${o.type})`).join(', ') });
    }
    results.push({ step: 'screenshot', result: screenshotPath });

    return results;
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command; screenshot failures are often transient
  2. Verify the temp directory (os.tmpdir()) is writable and has space
  3. Ensure the applet page/browser stays open through the run; update browser/automation deps if the session keeps dying
Defensive patterns

Strategy: try-catch

Validate before calling

const tmp = os.tmpdir();
fs.accessSync(tmp, fs.constants.W_OK); // throws early if tmp is not writable

Try / catch

try {
  await page.screenshot({ path: screenshotPath });
} catch (err) {
  console.error(`Screenshot failed: ${err?.message || err}`);
  // retry once after a short wait, then continue without the screenshot
}

Prevention

When it happens

Trigger: The screenshot call at clis/geogebra/hexagon.js:52 throws — e.g. the page/tab closed mid-run, the browser context ended, or the output path in os.tmpdir() is not writable.

Common situations: Headless browser crashed or disconnected; tmp directory permissions; screenshot attempted after navigation destroyed the target; disk full.

Related errors


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