From fd5f7ec095418fada36df9f40f22c37db2714b2b Mon Sep 17 00:00:00 2001 From: dyos22 Date: Tue, 11 Aug 2026 08:51:45 +0200 Subject: [PATCH 1/2] fix: count console.error output in Console errors summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The summary line "Console errors" and SUMMARY.md only counted uncaught page errors (agent-browser's errors command). Errors that the page catches and reports via console.error — fetch failures, error boundaries, caught exceptions, i.e. the most common error class in modern apps — were captured in console-output.log but reported as "Console errors: 0". Repro: a page calling console.error() three times reports 0 errors, while a page with one uncaught ReferenceError reports 1. Fix: merge [error]-type console entries (already collected for the viewer) with the uncaught errors, dedupe, and use the merged list for both the count and the SUMMARY.md report. Co-Authored-By: Claude Opus 5 --- src/commands/stop.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/commands/stop.ts b/src/commands/stop.ts index 2600ed3..a90434e 100644 --- a/src/commands/stop.ts +++ b/src/commands/stop.ts @@ -138,10 +138,20 @@ export async function stopCommand(options: StopOptions): Promise { } // Step 6: Count errors + // Uncaught page errors, as reported by agent-browser's `errors` command. const consoleErrorLines = consoleErrors .split('\n') .filter((l) => l.trim() && l.trim() !== 'No errors'); - const consoleErrorCount = consoleErrorLines.length > 0 && consoleErrors.trim() !== '' ? consoleErrorLines.length : 0; + // Also count console.error output. Modern apps catch most failures and + // report them via console.error (fetch failures, error boundaries, caught + // exceptions), so counting only uncaught errors under-reports the very + // thing the summary labels "Console errors". + const loggedErrorLines = consoleEntries + .filter((e) => e.text.startsWith('[error]')) + .map((e) => e.text); + const allConsoleErrorLines = [...new Set([...consoleErrorLines, ...loggedErrorLines])]; + const consoleErrorCount = allConsoleErrorLines.length; + const consoleErrorsReport = allConsoleErrorLines.join('\n'); // Extract errors from server log using multi-language patterns const serverErrorLines = extractServerErrors(serverLog); @@ -158,7 +168,7 @@ export async function stopCommand(options: StopOptions): Promise { port: session.port, videoPath: session.videoPath, screenshots, - consoleErrors, + consoleErrors: consoleErrorsReport, consoleErrorCount, serverLog, serverErrorCount, From f6c301615b8011e4694b59d4059a6988de2fa946 Mon Sep 17 00:00:00 2001 From: dyos22 Date: Tue, 11 Aug 2026 09:17:11 +0200 Subject: [PATCH 2/2] fix: raw-log fallback, normalized dedup, and merged terminal listing Review follow-ups: - Fall back to parsing [error] lines from raw console output when the JSON console fetch returns nothing. - Dedupe on normalized text (strip the "[error] " prefix) so the same error reported both as uncaught and as a console entry is counted once. - Print the merged list in the terminal error listing, matching the count. Co-Authored-By: Claude Opus 5 --- src/commands/stop.ts | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/commands/stop.ts b/src/commands/stop.ts index a90434e..d358252 100644 --- a/src/commands/stop.ts +++ b/src/commands/stop.ts @@ -146,10 +146,26 @@ export async function stopCommand(options: StopOptions): Promise { // report them via console.error (fetch failures, error boundaries, caught // exceptions), so counting only uncaught errors under-reports the very // thing the summary labels "Console errors". - const loggedErrorLines = consoleEntries + // Primary source: timestamped entries. Fallback: the raw console output, + // in case `console --json` was unavailable or returned an unexpected shape. + let loggedErrorLines = consoleEntries .filter((e) => e.text.startsWith('[error]')) .map((e) => e.text); - const allConsoleErrorLines = [...new Set([...consoleErrorLines, ...loggedErrorLines])]; + if (loggedErrorLines.length === 0 && consoleOutput.trim()) { + loggedErrorLines = consoleOutput.split('\n').filter((l) => l.startsWith('[error]')); + } + // Dedupe on normalized text so "Error: X" (uncaught) and "[error] Error: X" + // (console entry for the same error) are not double-counted. + const normalize = (l: string) => l.replace(/^\[error\]\s*/, '').trim(); + const seenErrors = new Set(); + const allConsoleErrorLines: string[] = []; + for (const line of [...consoleErrorLines, ...loggedErrorLines]) { + const key = normalize(line); + if (key && !seenErrors.has(key)) { + seenErrors.add(key); + allConsoleErrorLines.push(line); + } + } const consoleErrorCount = allConsoleErrorLines.length; const consoleErrorsReport = allConsoleErrorLines.join('\n'); @@ -251,11 +267,11 @@ export async function stopCommand(options: StopOptions): Promise { if (consoleErrorCount > 0) { console.log(''); console.log(chalk.red.bold('Console Errors:')); - for (const line of consoleErrorLines.slice(0, 10)) { + for (const line of allConsoleErrorLines.slice(0, 10)) { console.log(chalk.red(` ${line}`)); } - if (consoleErrorLines.length > 10) { - console.log(chalk.dim(` ... and ${consoleErrorLines.length - 10} more (see SUMMARY.md)`)); + if (allConsoleErrorLines.length > 10) { + console.log(chalk.dim(` ... and ${allConsoleErrorLines.length - 10} more (see SUMMARY.md)`)); } }