I'm running a Node.js application written in TypeScript. I use VS Code for debugging and run the app using ts-node, with source maps enabled.
I'm running the app with the --inspect flag and using VS Code's "attach" debug configuration. The debugger is listening on ws://localhost:9229. But:
- Chrome DevTools does not show any targets under
chrome://inspect. - Opening the raw URL (
http://localhost:9229/json) gives a valid JSON response. - Manually opening the DevTools with the
devtools://URL works, but:- Heap snapshot is stuck on loading and never completes.
My setup:
tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"sourceMap": true,
"outDir": "dist"
}
}
package.json scripts:
"scripts": {
"dev": "set NODE_ENV=DEV && concurrently \"npx tsc --watch\" \"nodemon --inspect --delay 5s -q dist/src/index.js\""
}
I'm using concurrently to run the TypeScript compiler and Nodemon in parallel. Terminal output when running the npm run dev:
[1] For more information, check the blog post at https://a.co/cUPnyil
[1] (Use `node --trace-warnings ...` to show where the warning was created)
[1] query: SELECT VERSION() AS `version`
[0]
// here as you can see the debugger is attached
[0] 11:35:08 pm - Found 0 errors. Watching for file changes.
[1] Debugger listening on ws://127.0.0.1:9229/c825031b-1285-49e7-bd94-a21d840c4137
[1] For help, see: https://nodejs.org/en/docs/inspector
[0]
[0] 11:35:08 pm - Found 0 errors. Watching for file changes.
[1] Debugger listening on ws://127.0.0.1:9229/c825031b-1285-49e7-bd94-a21d840c4137
VS Code launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Debug cluster",
"port": 9229,
"skipFiles": [
"<node_internals>/**",
"${workspaceFolder}/node_modules/**"
],
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/dist/**/*.js"]
}
]
}
Output of http://localhost:9229/json:
[
{
"description": "node.js instance",
"devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=localhost:9229/c825031b-1285-49e7-bd94-a21d840c4137",
"devtoolsFrontendUrlCompat": "devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:9229/c825031b-1285-49e7-bd94-a21d840c4137",
"title": "dist/src/index.js",
"type": "node",
"url": "file://<some>dist_src_index.js",
"webSocketDebuggerUrl": "ws://localhost:9229/c825031b-1285-49e7-bd94-a21d840c4137"
}
]
When I manually open the DevTools using the devtools:// URL above, it launches, but:
- Heap snapshot stays stuck on "Loading..."
- No memory profiling tools are usable.
Questions:
- Why is Chrome DevTools not listing my target under
chrome://inspecteven though--inspectis working? - Why is the heap snapshot stuck on loading even when manually opening the DevTools?
- Am I missing some config or doing something wrong in the way I'm starting/debugging the app?
I've:
- Confirmed that source maps are correctly generated.
- Verified the
.mapfiles exist indist/. - Ensured no firewall or antivirus is blocking port 9229.
- Disabled all Chrome extensions.
- Tried a clean rebuild.
- Used Chrome and Edge (same issue).
node --inspect-brk FULL_PATH_HERE