Skip to content

Debugger freezes when a breakpoint is hit on a large js file (>256KB) when current scope has local variables when debugging vscode extension webviews #2300

@a1exwang

Description

@a1exwang

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

2025-12-04.13-12-39.mp4
  1. Start from the webview sample in vscode-extension-samples
  2. Add a new js file in media/large.js and include it in the HTML.
  3. Add a breakpoint in line 3
  4. When breakpoint hits, the debugger freezes, unable to resume, stop, etc. I have to reload vscode.
  5. (But the Chrome DevTools work well even after vscode debugger freezes)
function getRandomData() {
    const _randomData = "...."; // 257KB long. From my testing, the variable size doesn't matter. What matter is the js file size. This example just use a simple way to make a large js file.)
    console.log("Generating random data..."); // <--------- Add a breakpoint here
    return _randomData[0];
}
setTimeout(_getRandomData, 10000);

Debugging the vscode-js-debugger project I can see the error roots from here:

const object = JSON.parse(message);

Somehow the input message JSON truncates at 256KB leaving a broken JSON when the script file is larger than 256KB. The broken message is something like:

{"id":1101,"sessionId":"B8FA00E601393C70BB8D058BB70BDD23","result":{
  "result":[{
    "configurable":true,"enumerable":true,"isOwn":true,"name":"_randomData","value": {
      "type":"string","value": "<long content but truncated here
Image

In some other cases, the broken message is a response for getScriptContent request.

Log File
the last exception: (If you need the full log you can ping me internally)

{"tag":"runtime.exception","timestamp":1764825754284,"message":"Unhandled error in debug adapter","metadata":{"message":"Unterminated string in JSON at position 262144 (line 1 column 262145)","stack":"SyntaxError: Unterminated string in JSON at position 262144 (line 1 column 262145)\n\tat JSON.parse (<anonymous>)\n\tat It._onMessage (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:63:7593)\n\tat c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:63:7103\n\tat L.fire (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:44:11104)\n\tat r.<anonymous> (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:108:30452)\n\tat By (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:12:51607)\n\tat r.n (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:12:50896)\n\tat r.emit (node:events:519:28)\n\tat qx.zY (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:12:65730)\n\tat qx.emit (node:events:519:28)\n\tat qx.dataMessage (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:12:43619)\n\tat qx.getData (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:12:42862)\n\tat qx.startLoop (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:12:39432)\n\tat qx._write (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:12:38716)\n\tat writeOrBuffer (node:internal/streams/writable:572:12)\n\tat _write (node:internal/streams/writable:501:10)\n\tat Writable.write (node:internal/streams/writable:510:10)\n\tat Socket.qy (c:\\Users\\<username>\\.vscode\\extensions\\ms-vscode.js-debug-nightly-2025.11.2517\\src\\extension.js:12:66450)\n\tat Socket.emit (node:events:519:28)\n\tat addChunk (node:internal/streams/readable:561:12)\n\tat readableAddChunkPushByteMode (node:internal/streams/readable:512:3)\n\tat Readable.push (node:internal/streams/readable:392:5)\n\tat TCP.onStreamRead (node:internal/stream_base_commons:189:23)"},"level":3}

Version: 1.106.3 (user setup)
Commit: bf9252a2fb45be6893dd8870c0bf37e2e1766d61
Date: 2025-11-25T22:28:18.024Z
Electron: 37.7.0
ElectronBuildId: 12781156
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26100

ms-vscode.js-debug-nightly: 2025.11.2517 (the bug also happens in the stable version)

launch.json:

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Run Extension",
			"type": "extensionHost",
			"request": "launch",
			"runtimeExecutable": "${execPath}",
			"debugWebviews": true,
			"autoAttachChildProcesses": true,
			"debugWebWorkerHost": true,
			"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
			"outFiles": ["${workspaceFolder}/out/**/*.js"],
			"preLaunchTask": "npm: watch",
			"trace": {
				"logFile": "C:/Users/**/debugger.log",
				"stdio": true,
			}
		}
	]
}

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions