豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit fad6bf8

Browse files
committed
fix: use 1-based line/column and fix wasm offsets in stack frames
1 parent ecef712 commit fad6bf8

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/formatters/ConsoleFormatter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export class ConsoleFormatter {
175175

176176
return [
177177
'### Stack trace',
178+
'Note: line and column numbers use 1-based indexing',
178179
this.#formatFragment(stackTrace.syncFragment),
179180
...stackTrace.asyncFragments.map(this.#formatAsyncFragment.bind(this)),
180181
].join('\n');
@@ -198,7 +199,8 @@ export class ConsoleFormatter {
198199
#formatFrame(frame: DevTools.DevTools.StackTrace.StackTrace.Frame): string {
199200
let result = `at ${frame.name ?? '<anonymous>'}`;
200201
if (frame.uiSourceCode) {
201-
result += ` (${frame.uiSourceCode.displayName()}:${frame.line}:${frame.column})`;
202+
const location = frame.uiSourceCode.uiLocation(frame.line, frame.column);
203+
result += ` (${location.linkText(/* skipTrim */ false, /* showColumnNumber */ true)})`;
202204
} else if (frame.url) {
203205
result += ` (${frame.url}:${frame.line}:${frame.column})`;
204206
}

tests/tools/console.test.js.snapshot

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ Message: warn> hello world
55
### Arguments
66
Arg #0: hello world
77
### Stack trace
8-
at bar (main.js:2:10)
9-
at foo (main.js:6:2)
10-
at Iife (main.js:10:2)
11-
at <anonymous> (main.js:9:0)
8+
at bar (main.js:3:11)
9+
at foo (main.js:7:3)
10+
at Iife (main.js:11:3)
11+
at <anonymous> (main.js:10:1)
1212
`;
1313

1414
exports[`console > get_console_message > applies source maps to stack traces of uncaught exceptions 1`] = `
1515
# test response
1616
ID: 1
1717
Message: error> Uncaught Error: b00m!
1818
### Stack trace
19-
at bar (main.js:2:8)
20-
at foo (main.js:6:2)
21-
at Iife (main.js:10:2)
22-
at <anonymous> (main.js:9:0)
19+
at bar (main.js:3:9)
20+
at foo (main.js:7:3)
21+
at Iife (main.js:11:3)
22+
at <anonymous> (main.js:10:1)
2323
`;
2424

2525
exports[`console > get_console_message > issues type > gets issue details with node id parsing 1`] = `

0 commit comments

Comments
 (0)