hubcap errors - Capture JavaScript exceptions with stack traces

When to use

Capture JavaScript exceptions with full stack traces as they occur. Use console if you need all console messages including non-error output like log, warn, info, and debug.

Usage

hubcap errors [--duration <duration>]

Arguments

None.

Flags

FlagTypeDefaultDescription
--durationduration0How long to capture; 0 = until interrupted

Output

NDJSON stream written to stdout. Each line is a JSON object representing a JavaScript exception.

FieldTypeDescription
textstringException text
lineNumbernumberLine number of the exception
columnNumbernumberColumn number of the exception
urlstringURL where the exception occurred
{"text":"TypeError: Cannot read properties of undefined (reading 'map')","lineNumber":42,"columnNumber":15,"url":"https://example.com/app.js"}

Errors

ConditionExit codeStderr
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Stream all JavaScript exceptions until Ctrl-C:

hubcap errors

Capture exceptions for 30 seconds:

hubcap errors --duration 30s

Count exceptions by message:

hubcap errors --duration 60s | jq -r '.message' | sort | uniq -c | sort -rn

Navigate to a page and check for errors:

hubcap goto --wait "https://example.com" && hubcap errors --duration 5s | jq -r '"[\(.text)]\n\(.url):\(.lineNumber)\n"'

See also

  • console - Capture all browser console messages
  • eval - Evaluate JavaScript in the browser
  • network - Stream network requests and responses