From 0c27151787e7f1b819141d92e88c2d41603ba05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Z=C3=BCnd?= Date: Wed, 4 Feb 2026 08:15:59 +0100 Subject: [PATCH] fix: use 1-based line/column and fix wasm offsets in stack frames --- src/formatters/ConsoleFormatter.ts | 4 +++- .../ConsoleFormatter.test.js.snapshot | 2 ++ tests/tools/console.test.js.snapshot | 18 ++++++++++-------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/formatters/ConsoleFormatter.ts b/src/formatters/ConsoleFormatter.ts index 9baaa7c34..c08108009 100644 --- a/src/formatters/ConsoleFormatter.ts +++ b/src/formatters/ConsoleFormatter.ts @@ -177,6 +177,7 @@ export class ConsoleFormatter { '### Stack trace', this.#formatFragment(stackTrace.syncFragment), ...stackTrace.asyncFragments.map(this.#formatAsyncFragment.bind(this)), + 'Note: line and column numbers use 1-based indexing', ].join('\n'); } @@ -198,7 +199,8 @@ export class ConsoleFormatter { #formatFrame(frame: DevTools.DevTools.StackTrace.StackTrace.Frame): string { let result = `at ${frame.name ?? ''}`; if (frame.uiSourceCode) { - result += ` (${frame.uiSourceCode.displayName()}:${frame.line}:${frame.column})`; + const location = frame.uiSourceCode.uiLocation(frame.line, frame.column); + result += ` (${location.linkText(/* skipTrim */ false, /* showColumnNumber */ true)})`; } else if (frame.url) { result += ` (${frame.url}:${frame.line}:${frame.column})`; } diff --git a/tests/formatters/ConsoleFormatter.test.js.snapshot b/tests/formatters/ConsoleFormatter.test.js.snapshot index f42a4b1f2..67a6e59e9 100644 --- a/tests/formatters/ConsoleFormatter.test.js.snapshot +++ b/tests/formatters/ConsoleFormatter.test.js.snapshot @@ -22,6 +22,7 @@ at foo (foo.ts:10:2) at bar (foo.ts:20:2) --- setTimeout ------------------------- at schedule (util.ts:5:2) +Note: line and column numbers use 1-based indexing `; exports[`ConsoleFormatter > toStringDetailed > formats a console.error message 1`] = ` @@ -57,6 +58,7 @@ at foo (foo.ts:10:2) at bar (foo.ts:20:2) --- setTimeout ------------------------- at schedule (util.ts:5:2) +Note: line and column numbers use 1-based indexing `; exports[`ConsoleFormatter > toStringDetailed > handles \"Execution context is not available\" error in args 1`] = ` diff --git a/tests/tools/console.test.js.snapshot b/tests/tools/console.test.js.snapshot index ce559f746..6d4f14bfd 100644 --- a/tests/tools/console.test.js.snapshot +++ b/tests/tools/console.test.js.snapshot @@ -5,10 +5,11 @@ Message: warn> hello world ### Arguments Arg #0: hello world ### Stack trace -at bar (main.js:2:10) -at foo (main.js:6:2) -at Iife (main.js:10:2) -at (main.js:9:0) +at bar (main.js:3:11) +at foo (main.js:7:3) +at Iife (main.js:11:3) +at (main.js:10:1) +Note: line and column numbers use 1-based indexing `; exports[`console > get_console_message > applies source maps to stack traces of uncaught exceptions 1`] = ` @@ -16,10 +17,11 @@ exports[`console > get_console_message > applies source maps to stack traces of ID: 1 Message: error> Uncaught Error: b00m! ### Stack trace -at bar (main.js:2:8) -at foo (main.js:6:2) -at Iife (main.js:10:2) -at (main.js:9:0) +at bar (main.js:3:9) +at foo (main.js:7:3) +at Iife (main.js:11:3) +at (main.js:10:1) +Note: line and column numbers use 1-based indexing `; exports[`console > get_console_message > issues type > gets issue details with node id parsing 1`] = `