{"record":{"id":"b31ca1374b971e31","repo":"jackwener/OpenCLI","slug":"failed-to-capture-geogebra-screenshot-err-mess","errorCode":null,"errorMessage":"Failed to capture GeoGebra screenshot: ${err?.message || err}","messagePattern":"Failed to capture GeoGebra screenshot: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/geogebra/triangle.js","lineNumber":50,"sourceCode":"    const r3 = requireGgbSuccess(await ggbEval(page, 'c=Circle(A,B)'), 'Failed to create circle c');\n    results.push({ step: 'c=Circle(A,B)', result: `ok (${r3.label || 'c'})` });\n\n    const r4 = requireGgbSuccess(await ggbEval(page, 'd=Circle(B,A)'), 'Failed to create circle d');\n    results.push({ step: 'd=Circle(B,A)', result: `ok (${r4.label || 'd'})` });\n\n    const r5 = requireGgbSuccess(await ggbEval(page, 'C=Intersect(c,d,1)'), 'Failed to create point C');\n    results.push({ step: 'C=Intersect(c,d,1)', result: `ok (${r5.label || 'C'})` });\n\n    const r6 = requireGgbSuccess(await ggbEval(page, 'Polygon(A,B,C)'), 'Failed to create triangle polygon');\n    results.push({ step: 'Polygon(A,B,C)', result: `ok (${r6.label || 'triangle created'})` });\n\n    const objectCount = await ggbWaitForObjectCount(page, 5);\n    const objects = await ggbListObjects(page);\n    const screenshotPath = path.join(os.tmpdir(), 'opencli-geogebra-triangle.png');\n    try {\n      await page.screenshot({ path: screenshotPath });\n    } catch (err) {\n      throw new CommandExecutionError(`Failed to capture GeoGebra screenshot: ${err?.message || err}`);\n    }\n    results.push({\n      step: `canvas has ${objectCount} objects`,\n      result: objects.map((obj) => `${obj.name}(${obj.type})`).join(', '),\n    });\n    results.push({ step: 'screenshot', result: screenshotPath });\n\n    return results;\n  },\n});\n","sourceCodeStart":32,"sourceCodeEnd":61,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/geogebra/triangle.js#L32-L61","documentation":"This CommandExecutionError wraps a failure of page.screenshot() inside the `geogebra triangle` command. The construction succeeded but Playwright could not write the PNG — the wrapper preserves the underlying Playwright message for diagnosis.","triggerScenarios":"`geogebra triangle ...` completing its construction but failing at page.screenshot({path}) — e.g. the target tab was closed/navigated during the run, the page was destroyed, or Playwright cannot write to the temp path.","commonSituations":"Tab closed by user or timeout mid-command; headless browser shutdown; os.tmpdir() unwritable (permissions, full disk, read-only container); screenshot taken during navigation.","solutions":["Re-run the command; transient tab races usually clear","Check the temp directory is writable (permissions, disk space) — screenshotPath uses os.tmpdir()/opencli-geogebra-triangle.png","Keep the bound tab open and on www.geogebra.org for the whole command","Read the appended Playwright message: 'Target closed' means re-bind the tab; filesystem errors mean fix the tmpdir"],"exampleFix":"// before\n# error: Failed to capture GeoGebra screenshot: EACCES: permission denied, open '/tmp/opencli-geogebra-triangle.png'\n// after\nexport TMPDIR=$HOME/tmp && mkdir -p $HOME/tmp && opencli geogebra triangle --a 3 --b 4 --c 5","handlingStrategy":"retry","validationCode":"// ensure temp dir writable before the command\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nfs.accessSync(os.tmpdir(), fs.constants.W_OK);","typeGuard":null,"tryCatchPattern":"try {\n  await run('geogebra', 'triangle', '--a', '3', '--b', '4', '--c', '5');\n} catch (err) {\n  if (/Failed to capture GeoGebra screenshot/.test(err.message)) {\n    if (/Target closed|navigat/.test(err.message)) { await rebindTab(); return retry(); }\n    if (/EACCES|ENOSPC|ENOENT/.test(err.message)) { fixTmpdirPermissions(); return retry(); }\n  }\n  throw err;\n}","preventionTips":["Don't close or navigate the bound tab while the command runs","Verify TMPDIR/os.tmpdir() is writable, especially in containers and CI","Monitor disk space; the screenshot needs free space in the temp directory"],"tags":["playwright","screenshot","filesystem","geogebra"],"backgroundTag":"screenshot-capture-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}