jackwener/OpenCLI · error · CommandExecutionError

`Failed to inspect GeoGebra object: ${err?.message || err}`

Error message

`Failed to inspect GeoGebra object: ${err?.message || err}`

What it means

This CommandExecutionError wraps any exception thrown by page.evaluate while running the in-page existence probe for `geogebra info`. It means the browser bridge call itself failed (page crashed, navigation tore down the execution context, the evaluate script threw outside the guarded inner try, or the bridge envelope could not be unwrapped), not that the object is absent. The original error message is appended for diagnosis.

Source

Thrown at clis/geogebra/info.js:39

    await ensureApplet(page);

    let exists;
    try {
      exists = unwrapBridgeEnvelope(await page.evaluate(`
        (name => {
          try {
            if (typeof ggbApplet === 'undefined' || typeof ggbApplet.getObjectType !== 'function') {
              return { error: 'ggbApplet is not ready' };
            }
            return { ok: true, exists: ggbApplet.getObjectType(name) !== '' };
          } catch (err) {
            return { error: err?.message || String(err) };
          }
        })
        (${JSON.stringify(objName)})
      `));
    } catch (err) {
      throw new CommandExecutionError(`Failed to inspect GeoGebra object: ${err?.message || err}`);
    }
    if (!exists || typeof exists !== 'object' || Array.isArray(exists)) {
      throw new CommandExecutionError('GeoGebra object existence probe returned malformed result');
    }
    if (exists.error) {
      throw new CommandExecutionError(`Failed to inspect GeoGebra object: ${exists.error}`);
    }
    if (exists.ok !== true || typeof exists.exists !== 'boolean') {
      throw new CommandExecutionError('GeoGebra object existence probe returned malformed result');
    }
    if (exists.exists === false) {
      throw new EmptyResultError(`geogebra info ${objName}`, `Object "${objName}" not found on the canvas.`);
    }

    const properties = ['type', 'value', 'definition', 'command', 'caption', 'visible', 'color'];
    const rows = [];
    for (const prop of properties) {
      const val = await ggbGetProperty(page, objName, prop);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run the command; transient navigation races usually resolve on retry
  2. Re-bind the tab to www.geogebra.org (run a browser workspace bind/navigation command) before `geogebra info`
  3. Run `geogebra eval` once to ensure the applet is loaded via ensureApplet, then retry info
  4. Inspect the appended message for the underlying Playwright error and fix that root cause

Example fix

// before
opencli geogebra info --name A   # fails after tab navigated
// after
opencli browser navigate https://www.geogebra.org/geometry && opencli geogebra eval --code 'ggbApplet.evalCommand("A=(1,2)")' && opencli geogebra info --name A
Defensive patterns

Strategy: try-catch

Validate before calling

// before running: ensure tab is still bound and on the applet page
const url = await page.url();
if (!url.includes('geogebra.org')) throw new Error('Tab left geogebra.org; re-bind before geogebra info');

Type guard

function isEnvelope(v) { return v !== null && typeof v === 'object' && !Array.isArray(v); }

Try / catch

try {
  await run('geogebra', 'info', '--name', 'A');
} catch (err) {
  if (/Failed to inspect GeoGebra object/.test(err.message)) {
    await rebindTab('https://www.geogebra.org/geometry');
    await run('geogebra', 'eval', '--code', '1+1'); // re-init applet
    return retry();
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling `geogebra info --name A` when the tab navigated/closed mid-command, when page.evaluate rejects (execution context destroyed), or when the async evaluate result is a rejected promise the outer try/catch sees before unwrapping.

Common situations: Running the command against an already-bound tab that the user navigated away from www.geogebra.org; headless browser closed by timeout; applet iframe reload racing the probe.

Related errors


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