Console messages from an earlier navigation lose their stack trace
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- devtools, typescript
- Domain
- devtools
Research direction
Start in src/devtools/DevtoolsUtils.ts at createStackTrace(), where the 1 s script wait's .catch() swallows the timeout, then follow its callers ConsoleFormatter and SymbolizedError, and formatFrame for the 0-based output. Reproduce by navigating a page with a script and listing preserved console messages with stack traces. Done means old frames keep their URL, 1-based line and column, and never resolve against a different page's script with a reused id. A pull request (#3397) is already open for this, so check it before starting.
Written by the indexing model from the issue text.
Description
Description of the bug
After the page navigates, console messages and uncaught errors from the previous page lose their whole stack trace:
list_console_messageswithincludePreservedMessages: trueandincludeStackTraces: truelists them without anyat ...lines.get_console_messagefor one of them has no### Stack tracesection.
Before the navigation, the same messages have full stack traces. After it, each of these calls first waits about 1 s for the old page's scripts. A reload does the same: the messages logged before it lose their stack, while the identical messages logged after it keep theirs.
After a navigation to another site, the old messages can instead get the frames of the new page's scripts. In the reproduction below, logFromA from a.js is then printed as a frame of c1.js, a script of the new page.
createStackTrace() (src/devtools/DevtoolsUtils.ts) waits up to 1 s for every script in the stack trace, but the .catch() on that wait has no handler, so it doesn't catch the timeout. DevTools drops the old page's scripts on navigation, so the wait times out as soon as one script id of the stack is not in use on the new page, createStackTrace() throws, and both callers (ConsoleFormatter for console messages, SymbolizedError for uncaught errors) drop the stack.
The wrong frames have another cause: script ids are only unique within a renderer process, and the process of a new site numbers its scripts from the start again. When every script id of an old stack is in use again, nothing times out, and DevTools resolves the old frames against the new page's scripts.
Adding a handler alone isn't enough: frames of scripts that are gone have no UISourceCode, and formatFrame prints their raw 0-based position (line 1, column 10 instead of a.js:2:11 for logFromA in the reproduction below), while the output says line and column numbers are 1-based.
Reproduction
Serve three files:
a.html:<!doctype html><title>a</title><script src="/a.js"></script>b.html:<!doctype html><title>b</title>a.js:
function logFromA() {
console.log("message from A");
}
logFromA();
function throwFromA() {
throw new Error("uncaught from A");
}
setTimeout(throwFromA, 0);
Then call the tools (output trimmed to the two messages from a.js):
new_page {"url": "http://127.0.0.1:PORT/a.html"}
list_console_messages {"pageId": 2, "includeStackTraces": true}
msgid=1 [log] message from A (1 args)
at logFromA (a.js:2:11)
at (a.js:4:1)
msgid=2 [error] Uncaught Error: uncaught from A (0 args)
at throwFromA (a.js:6:9)
--- setTimeout -------------------------
at (a.js:8:1)
navigate_page {"pageId": 2, "type": "url", "url": "http://127.0.0.1:PORT/b.html"}
list_console_messages {"pageId": 2, "includePreservedMessages": true, "includeStackTraces": true}
(took 1003 ms)
msgid=1 [log] message from A (1 args)
msgid=2 [error] Uncaught Error: uncaught from A (0 args)
get_console_message {"pageId": 2, "msgid": 1}
(took 1004 ms)
ID: 1
Message: log> message from A
### Arguments
Arg #0: message from A
get_console_message {"pageId": 2, "msgid": 2}
(took 1007 ms)
ID: 2
Message: error> Uncaught Error: uncaught from A
With navigate_page {"pageId": 2, "type": "reload"} instead of the navigation to b.html (msgid 3, a Failed to load resource 404, left out):
list_console_messages {"pageId": 2, "includePreservedMessages": true, "includeStackTraces": true}
(took 1005 ms)
msgid=1 [log] message from A (1 args)
msgid=2 [error] Uncaught Error: uncaught from A (0 args)
msgid=4 [log] message from A (1 args)
at logFromA (a.js:2:11)
at (a.js:4:1)
msgid=5 [error] Uncaught Error: uncaught from A (0 args)
at throwFromA (a.js:6:9)
--- setTimeout -------------------------
at (a.js:8:1)
For another site, serve c.html and four small scripts from the same server and open c.html through localhost instead of 127.0.0.1:
c.html:<!doctype html><title>c</title><script src="/c1.js"></script><script src="/c2.js"></script><script src="/c3.js"></script><script src="/c4.js"></script>c1.jstoc4.js, the same for each number:
function fromC1() {
return 1;
}
fromC1();
With navigate_page {"pageId": 2, "type": "url", "url": "http://localhost:PORT/c.html"} instead of the navigation to b.html:
list_console_messages {"pageId": 2, "includePreservedMessages": true, "includeStackTraces": true}
(took 3 ms)
msgid=1 [log] message from A (1 args)
at logFromA (c1.js:2:11)
at (c1.js:4:1)
msgid=2 [error] Uncaught Error: uncaught from A (0 args)
at throwFromA (c1.js:6:9)
--- setTimeout -------------------------
at (c1.js:8:1)
Expectation
Messages from an earlier navigation keep their stack traces. Their scripts are gone, so the frames can't be mapped any more, but each frame still has its URL, line and column, so logFromA should print as at logFromA (http://127.0.0.1:PORT/a.js:2:11), 1-based like the rest of the output. For a plain script like a.js that is the same position as before the navigation. No frame should be printed as a frame of a different script that reuses its script id.
MCP configuration
--headless --isolated --no-usage-statistics
Chrome DevTools MCP version
main at 8d009e8 (local build, 1.12.0)
Chrome version
156.0.8078.79
Node version
24.20.0
Operating system
Windows
Extra checklist
- I want to provide a PR to fix this bug
- Dominant language
- TypeScript
- Stars
- 59.8k
- Forks
- 4.8k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 162
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ChromeDevTools/chrome-devtools-mcp
-
feature
Difficulty 1/5 Under an hour Newbie friendliness 78/100
ChromeDevTools/chrome-devtools-mcp#3689 ·
Maintainers usually reply within 1 day
-
`evaluate_script` `sourcePath` http(s) URLs are mangled into `file://` pathsMay be free again A pull request for this issue was closed without being merged. Opencollecting-feedback
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ChromeDevTools/chrome-devtools-mcp#3453 · 3 comments ·
Maintainers usually reply within 1 day
-
collecting-feedback feature
Difficulty 2/5 Half a day Newbie friendliness 76/100
ChromeDevTools/chrome-devtools-mcp#3225 · 3 comments ·
Maintainers usually reply within 1 day
-
confirmed p3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ChromeDevTools/chrome-devtools-mcp#2947 · 1 comment ·
Maintainers usually reply within 1 day
-
Project Migration: Moving to devtools-frontendPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 5/5 Over a week Newbie friendliness 1/100
ChromeDevTools/chrome-devtools-mcp#3648 ·
Maintainers usually reply within 1 day
All issues in ChromeDevTools/chrome-devtools-mcp
Similar issues
-
bug from-app needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
nightly-labs/openbot#21303 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ADORSYS-GIS/CoopData#282 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
OHDSI/Data2Evidence#3816 ·
Maintainers usually reply within 3 days
-
`ovsx verify` fails for a version older than the 100 newest of an extensionPossibly taken @trivikr claimed this today. Opencli
Difficulty 2/5 1-3 hours Newbie friendliness 81/100
eclipse-openvsx/openvsx#2482 · 2 comments ·
Maintainers usually reply within 1 day
-
bug builder-vite hmr sev:S3
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
storybookjs/storybook#37965 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day