jackwener/OpenCLI · error · CommandExecutionError
Failed to execute GeoGebra command: ${err?.message || err}
Error message
Failed to execute GeoGebra command: ${err?.message || err} What it means
ggbEval() runs a GeoGebra command string through ggbApplet.evalCommandGetLabels inside the page. If the page.evaluate call itself rejects — the command script throws, the page context is destroyed, or evaluation times out — it throws CommandExecutionError 'Failed to execute GeoGebra command: ...' wrapping the underlying error. This is a transport/evaluation failure, distinct from command-level GeoGebra errors reported via result.ok=false.
Source
Thrown at clis/geogebra/utils.js:154
return Array.isArray(names) ? names : [];
};
const beforeCount = collectNames().length;
const label = ggbApplet.evalCommandGetLabels(cmd);
const afterCount = collectNames().length;
const dialogText = [...document.querySelectorAll('[role="dialog"], .gwt-DialogBox')]
.map(node => node.textContent?.trim() || '')
.find(text => /error|unknown command|错误|未知的指令/i.test(text)) || '';
return {
ok: label !== '' || afterCount > beforeCount,
label,
beforeCount,
afterCount,
error: dialogText || null,
};
})(${JSON.stringify(cmd)})
`));
} catch (err) {
throw new CommandExecutionError(`Failed to execute GeoGebra command: ${err?.message || err}`);
}
if (!isPlainObject(result) || typeof result.ok !== 'boolean') {
throw new CommandExecutionError('GeoGebra command returned malformed result');
}
return result;
}
/**
* List all currently known GeoGebra objects, optionally filtered by type.
*/
export async function ggbListObjects(page, filterType) {
const normalizedFilter = filterType ? String(filterType).toLowerCase() : '';
let objects;
try {
objects = unwrapBridgeEnvelope(await page.evaluate(`
(filterType => {
const api = ggbApplet;
let names = api.getAllObjectNames();View on GitHub (pinned to 49907e53dc)
Solutions
- Read the wrapped err message: 'Target closed'/'context destroyed' means recreate or re-navigate the page, then retry.
- Retry the command once after ensureApplet(page) — transient dialog/DOM races usually clear.
- Reduce command complexity (split large constructions into multiple evalCommand calls) to avoid renderer freezes.
- Serialize access to the page: don't run multiple tools concurrently against the same browser tab.
Example fix
// before await ggbEval(page, hugeCommand); // evaluate times out // after for (const c of splitCommands(hugeCommand)) await ggbEval(page, c);
Defensive patterns
Strategy: try-catch
Validate before calling
if (page.isClosed() || !page.url().includes('geogebra.org/geometry')) await ensureApplet(page); Type guard
null
Try / catch
try { await ggbEval(page, cmd); } catch (e) { if (String(e.message).includes('Failed to execute')) { await ensureApplet(page); await ggbEval(page, cmd); } else throw e; } Prevention
- Keep commands modest in size; split big constructions.
- Never run concurrent tools against the same tab.
- Dismiss/avoid GeoGebra UI dialogs before executing commands.
- Recreate the page after context-destroyed errors instead of retrying in place.
When it happens
Trigger: The in-page async helper throws unexpectedly (dialog detection code hitting a detached DOM node), execution context destroyed mid-evaluation, page crashed during evalCommand for a huge construction, or the page navigated away while the command ran.
Common situations: Very large/complex commands freezing the renderer until evaluate times out, concurrent tools driving the same page causing re-entrancy, automation framework closing pages between steps, or GeoGebra UI dialogs (e.g. save prompts) stealing focus and breaking the helper's assumptions.
Related errors
- Failed to detect GeoGebra applet: ${err?.message || err}
- ggbApplet not available after waiting. Make sure the GeoGebr
- GeoGebra command returned malformed result
- Unexpected Claude probe: ${JSON.stringify(result)}
- Failed to send message
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b45c15fadeabce81.
Report an issue: GitHub.