Skip to content

vibium eval shows empty "script exception:" message instead of the real error #221

Description

@Jhoan0714

Description

When a JavaScript expression fails during CLI vibium eval or MCP browser_evaluate, Vibium reports a generic error with no useful detail:

Error: failed to evaluate: script exception:

The browser does throw a real exception (e.g. SecurityError, ReferenceError), but Vibium fails to read it from the WebDriver BiDi response and surfaces an empty message instead.

Steps to Reproduce

  1. Run a script that throws on the default page (about:blank - lazy launch):

    vibium eval "localStorage.setItem('key', 'value')"

    Or navigate first and throw a reference error:

    vibium go "https://example.com"
    vibium eval "undefinedVariable"

Expected Behavior

The CLI should show the actual JavaScript exception message, for example:

Error: failed to evaluate: script exception: SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

or:

Error: failed to evaluate: script exception: ReferenceError: undefinedVariable is not defined

Actual Behavior

Error: failed to evaluate: script exception:

The message after script exception: is always empty, making debugging impossible.

Root Cause

CLI and MCP evaluation go through browser_evaluateh.client.Evaluate() in clicker/internal/bidi/script.go.

When a script throws, the WebDriver BiDi spec returns type: "exception" with details in exceptionDetails (including text, lineNumber, stackTrace), not in result:

{
  "type": "exception",
  "exceptionDetails": {
    "text": "SecurityError: Failed to read the 'localStorage' property...",
    "lineNumber": 1,
    "columnNumber": 1
  }
}

Vibium only parses type and result, and builds the error from the wrong field:

// clicker/internal/bidi/script.go
if evalResult.Type == "exception" {
    return nil, fmt.Errorf("script exception: %s", string(evalResult.Result))
}

evalResult.Result is empty for exception responses, so the error message is blank.

Impacted Operations

  • CLI: vibium eval
  • MCP: browser_evaluate
  • Any daemon/MCP handler that uses bidi.Client.Evaluate() or bidi.Client.CallFunction() in clicker/internal/bidi/script.go

Proposed Fix

In clicker/internal/bidi/script.go, parse exceptionDetails when type == "exception" and use exceptionDetails.text (and optionally line/stack) in the error message. Apply the same fix to both Evaluate() and CallFunction().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions