microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.51k stars 29.39k forks source link

Unbound breakpoints for node.js application #122752

Closed Nickk4 closed 3 years ago

Nickk4 commented 3 years ago

Issue Type: Bug

I have a full Node applications for which I'm unable to debug in VSC because breakpoints always remain unbound: https://stackoverflow.com/q/67137593. To make the problem easier to identify I created a very simple Node Express app to see if the problem would also be there, which it is (see below how I reproduce it). Any idea why the breakpoints remain unbound for this simple application?

Steps to Reproduce:

  1. Start a new workspace and create an simple Node Express app 1a. npm init, npm install express --save. 1b. Create app.js with the code:

    const express = require('express')
    const app = express()
    const port = 3000
    app.get('/', (req, res) => {
    res.send('Hello World!')
    })
    app.listen(port, () => {
    console.log(`Example app listening at http://localhost:${port}`)
    })
  2. Create a debug launch setup:

    {
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-node",
            "request": "launch",
            "name": "Test Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}\\app.js"
        }
    ]
    }
  3. Set a breakpoint in VSC, for example on the line const port = 3000.

  4. Run the debug configuration. Result: all breakpoints are unbound.

My Settings.json file:

{
    "workbench.colorTheme": "Oceanic Next (dimmed bg)",
    "files.autoSave": "onFocusChange",
    "editor.minimap.enabled": true,
    "workbench.statusBar.visible": true,
    "workbench.activityBar.visible": true,
    "editor.formatOnSave": false,

    "workbench.colorCustomizations": {
      "statusBar.background": "#333333",
      "statusBar.noFolderBackground": "#333333",
      "statusBar.debuggingBackground": "#263238"
    },
    "editor.fontSize": 16,

    "css.validate": false,
    "scss.validate": false,
    "less.validate": false,
    "editor.wordWrap": "on",

    "telemetry.enableTelemetry": false,
    "update.enableWindowsBackgroundUpdates": false,
    "explorer.confirmDelete": false,
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "window.zoomLevel": 0,
    "workbench.enableExperiments": false,
    "vscode-mysql.enableTelemetry": false,
    "workbench.startupEditor": "newUntitledFile",
    "editor.largeFileOptimizations": false,
    "diffEditor.ignoreTrimWhitespace": false,
    "remote.SSH.remotePlatform": {
      "xxx": "linux"
    },
    "debug.allowBreakpointsEverywhere": true,
    "terminal.integrated.automationShell.linux": "",
}

VS Code version: Code 1.55.2 (3c4e3df9e89829dce27b7b5c24508306b151f30d, 2021-04-13T09:35:57.887Z) OS version: Windows_NT x64 10.0.19042

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz (4 x 2394)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|7.92GB (1.41GB free)| |Process Argv|--crash-reporter-id e044bb89-5f61-48c3-b5e9-d1b7e95732f3| |Screen Reader|no| |VM|0%|
Extensions (16) Extension|Author (truncated)|Version ---|---|--- vscode-database|baj|2.2.3 path-intellisense|chr|2.3.0 jsrefactor|cms|2.20.6 vscode-svgviewer|css|2.0.0 vscode-eslint|dba|2.1.20 EditorConfig|Edi|0.16.4 prettier-vscode|esb|6.3.2 auto-close-tag|for|0.5.10 auto-rename-tag|for|0.1.6 vscode-mysql|for|0.4.0 remote-ssh|ms-|0.65.4 remote-ssh-edit|ms-|0.65.4 debugger-for-chrome|msj|4.12.12 color-highlight|nau|2.3.0 vscode-react-refactor|pla|1.1.3 vscode-paste-and-indent|Rub|0.0.8 (1 theme extensions excluded)
connor4312 commented 3 years ago

/jsDebugLogs

Nickk4 commented 3 years ago

Thanks, the trace log is as follows:

{"timestamp":1620056708187,"tag":"runtime.welcome","level":1,"message":"js-debug v1.55.2 started","metadata":{"os":"win32 x64","nodeVersion":"v12.18.3","adapterVersion":"1.55.2"}}
{"tag":"dap.receive","timestamp":1620056708127,"metadata":{"connectionId":0,"message":{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"pwa-node","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb","supportsProgressReporting":true,"supportsInvalidatedEvent":true},"type":"request","seq":1}},"level":0}
{"tag":"dap.send","timestamp":1620056708128,"metadata":{"connectionId":0,"message":{"seq":1,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsFunctionBreakpoints":false,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"exceptionBreakpointFilters":[{"filter":"all","label":"Caught Exceptions","default":false,"supportsCondition":true,"description":"Breaks on all throw errors, even if they're caught later.","conditionDescription":"error.name == \"MyError\""},{"filter":"uncaught","label":"Uncaught Exceptions","default":false,"supportsCondition":true,"description":"Breaks only on errors or promise rejections that are not handled.","conditionDescription":"error.name == \"MyError\""}],"supportsStepBack":false,"supportsSetVariable":true,"supportsRestartFrame":true,"supportsGotoTargetsRequest":false,"supportsStepInTargetsRequest":false,"supportsCompletionsRequest":true,"supportsModulesRequest":false,"additionalModuleColumns":[],"supportedChecksumAlgorithms":[],"supportsRestartRequest":true,"supportsExceptionOptions":false,"supportsValueFormattingOptions":true,"supportsExceptionInfoRequest":true,"supportTerminateDebuggee":false,"supportsDelayedStackTraceLoading":true,"supportsLoadedSourcesRequest":true,"supportsLogPoints":true,"supportsTerminateThreadsRequest":false,"supportsSetExpression":false,"supportsTerminateRequest":false,"completionTriggerCharacters":[".","[","\"","'"],"supportsBreakpointLocationsRequest":true,"supportsClipboardContext":true,"supportsExceptionFilterOptions":true}}},"level":0}
{"tag":"dap.send","timestamp":1620056708128,"metadata":{"connectionId":0,"message":{"seq":2,"type":"event","event":"initialized","body":{}}},"level":0}
{"tag":"dap.receive","timestamp":1620056708161,"metadata":{"connectionId":0,"message":{"command":"launch","arguments":{"type":"pwa-node","name":"Test Launch Program","request":"launch","trace":{"console":false,"level":"verbose","stdio":true,"logFile":"c:\\Users\\Nickk\\AppData\\Roaming\\Code\\logs\\20210503T174230\\exthost1\\ms-vscode.js-debug\\vscode-debugadapter-b17e2c23.json.gz","tags":[]},"outputCapture":"console","timeout":10000,"timeouts":{},"showAsyncStacks":true,"skipFiles":["<node_internals>/**"],"smartStep":true,"sourceMaps":true,"pauseForSourceMap":false,"rootPath":"C:\\Users\\Nickk\\Documents\\vsc simple node express app","outFiles":["C:\\Users\\Nickk\\Documents\\vsc simple node express app/**/*.js","!**/node_modules/**"],"sourceMapPathOverrides":{"webpack:///./~/*":"c:\\Users\\Nickk\\Documents\\vsc simple node express app/node_modules/*","webpack:////*":"/*","webpack://?:*/*":"c:\\Users\\Nickk\\Documents\\vsc simple node express app/*","webpack:///([a-z]):/(.+)":"$1:/$2","meteor://💻app/*":"c:\\Users\\Nickk\\Documents\\vsc simple node express app/*"},"enableContentValidation":true,"cascadeTerminateToConfigurations":[],"__workspaceFolder":"c:\\Users\\Nickk\\Documents\\vsc simple node express app","__autoExpandGetters":false,"__breakOnConditionalError":false,"cwd":"c:\\Users\\Nickk\\Documents\\vsc simple node express app","env":{},"envFile":null,"localRoot":null,"remoteRoot":null,"autoAttachChildProcesses":true,"runtimeSourcemapPausePatterns":[],"program":"C:\\Users\\Nickk\\Documents\\vsc simple node express app\\app.js","stopOnEntry":false,"console":"internalConsole","restart":false,"args":[],"runtimeExecutable":"node","runtimeVersion":"default","runtimeArgs":[],"profileStartup":false,"attachSimplePort":null,"killBehavior":"forceful","__configurationTarget":5,"__workspaceCachePath":"c:\\Users\\Nickk\\AppData\\Roaming\\Code\\User\\workspaceStorage\\2b82b609ffa86b370c0b08d8df7adaa6\\ms-vscode.js-debug","__sessionId":"d908a9b8-cf16-4867-a02f-470a5b670684"},"type":"request","seq":2}},"level":0}
{"tag":"dap.send","timestamp":1620056708163,"metadata":{"connectionId":0,"message":{"seq":3,"type":"event","event":"output","body":{"category":"telemetry","output":"js-debug/launch","data":{"type":"pwa-node","request":"launch","os":"win32 x64","nodeVersion":"v12.18.3","adapterVersion":"1.55.2","parameters":"{\"type\":\"pwa-node\",\"name\":\"<string>\",\"request\":\"launch\",\"trace\":{\"console\":false,\"level\":\"<string>\",\"stdio\":true,\"logFile\":\"<string>\",\"tags\":[]},\"outputCapture\":\"console\",\"timeout\":10000,\"timeouts\":{},\"showAsyncStacks\":true,\"skipFiles\":[\"<string>\"],\"smartStep\":true,\"sourceMaps\":true,\"pauseForSourceMap\":false,\"resolveSourceMapLocations\":[\"<string>\",\"<string>\"],\"rootPath\":\"<string>\",\"outFiles\":[\"<string>\",\"<string>\"],\"sourceMapPathOverrides\":{\"webpack:///./~/*\":\"<string>\",\"webpack:////*\":\"<string>\",\"webpack://?:*/*\":\"<string>\",\"webpack:///([a-z]):/(.+)\":\"<string>\",\"meteor://💻app/*\":\"<string>\"},\"enableContentValidation\":true,\"cascadeTerminateToConfigurations\":[],\"__workspaceFolder\":\"<string>\",\"__autoExpandGetters\":false,\"__breakOnConditionalError\":false,\"cwd\":\"<string>\",\"env\":{},\"envFile\":null,\"localRoot\":null,\"remoteRoot\":null,\"autoAttachChildProcesses\":true,\"runtimeSourcemapPausePatterns\":[],\"program\":\"<string>\",\"stopOnEntry\":false,\"console\":\"internalConsole\",\"restart\":false,\"args\":[],\"runtimeExecutable\":\"node\",\"runtimeVersion\":\"default\",\"runtimeArgs\":[],\"profileStartup\":false,\"attachSimplePort\":null,\"killBehavior\":\"forceful\",\"__configurationTarget\":5,\"__workspaceCachePath\":\"<string>\",\"__sessionId\":\"<string>\"}"}}}},"level":0}
{"tag":"dap.send","timestamp":1620056708170,"metadata":{"connectionId":0,"message":{"seq":4,"type":"event","event":"output","body":{"category":"console","output":"Verbose logs are written to:\nc:\\Users\\Nickk\\AppData\\Roaming\\Code\\logs\\20210503T174230\\exthost1\\ms-vscode.js-debug\\vscode-debugadapter-b17e2c23.json.gz\n"}}},"level":0}
{"tag":"dap.receive","timestamp":1620056708183,"metadata":{"connectionId":0,"message":{"command":"setBreakpoints","arguments":{"source":{"name":"app.js","path":"c:\\Users\\Nickk\\Documents\\vsc simple node express app\\app.js"},"lines":[3,6],"breakpoints":[{"line":3},{"line":6}],"sourceModified":false},"type":"request","seq":3}},"level":0}
{"tag":"dap.send","timestamp":1620056708187,"metadata":{"connectionId":0,"message":{"seq":5,"type":"response","request_seq":3,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"id":1,"verified":false,"message":"Unbound breakpoint"},{"id":2,"verified":false,"message":"Unbound breakpoint"}]}}},"level":0}
{"tag":"dap.receive","timestamp":1620056708295,"metadata":{"connectionId":0,"message":{"command":"setExceptionBreakpoints","arguments":{"filters":[],"filterOptions":[]},"type":"request","seq":4}},"level":0}
{"tag":"dap.send","timestamp":1620056708295,"metadata":{"connectionId":0,"message":{"seq":6,"type":"response","request_seq":4,"command":"setExceptionBreakpoints","success":true,"body":{}}},"level":0}
{"tag":"dap.receive","timestamp":1620056708299,"metadata":{"connectionId":0,"message":{"command":"configurationDone","type":"request","seq":5}},"level":0}
{"tag":"dap.send","timestamp":1620056708299,"metadata":{"connectionId":0,"message":{"seq":7,"type":"response","request_seq":5,"command":"configurationDone","success":true,"body":{}}},"level":0}
{"tag":"dap.receive","timestamp":1620056708308,"metadata":{"connectionId":0,"message":{"command":"threads","type":"request","seq":6}},"level":0}
{"tag":"dap.send","timestamp":1620056708308,"metadata":{"connectionId":0,"message":{"seq":8,"type":"response","request_seq":6,"command":"threads","success":true,"body":{"threads":[]}}},"level":0}
{"tag":"runtime.launch","timestamp":1620056708507,"message":"Using binary at","metadata":{"location":"C:\\Program Files\\nodejs\\node.exe","executable":"node"},"level":1}
{"tag":"runtime.launch","timestamp":1620056709023,"message":"Discovered version","metadata":{"version":"v9.8.0"},"level":1}
{"tag":"dap.send","timestamp":1620056709282,"metadata":{"connectionId":0,"message":{"seq":9,"type":"event","event":"output","body":{"category":"console","output":"C:\\Program Files\\nodejs\\node.exe .\\app.js"}}},"level":0}
{"tag":"runtime.launch","timestamp":1620056709657,"message":"Launched successfully","metadata":{"name":"P"},"level":1}
{"tag":"dap.send","timestamp":1620056709657,"metadata":{"connectionId":0,"message":{"seq":10,"type":"response","request_seq":2,"command":"launch","success":true,"body":{}}},"level":0}
{"tag":"dap.receive","timestamp":1620056709780,"metadata":{"connectionId":0,"message":{"command":"loadedSources","type":"request","seq":7}},"level":0}
{"tag":"dap.send","timestamp":1620056709780,"metadata":{"connectionId":0,"message":{"seq":11,"type":"response","request_seq":7,"command":"loadedSources","success":true,"body":{"sources":[]}}},"level":0}
{"tag":"dap.receive","timestamp":1620056709862,"metadata":{"connectionId":0,"message":{"command":"breakpointLocations","arguments":{"source":{"name":"app.js","path":"c:\\Users\\Nickk\\Documents\\vsc simple node express app\\app.js"},"line":3},"type":"request","seq":8}},"level":0}
{"tag":"dap.receive","timestamp":1620056709862,"metadata":{"connectionId":0,"message":{"command":"breakpointLocations","arguments":{"source":{"name":"app.js","path":"c:\\Users\\Nickk\\Documents\\vsc simple node express app\\app.js"},"line":6},"type":"request","seq":9}},"level":0}
{"tag":"dap.send","timestamp":1620056709862,"metadata":{"connectionId":0,"message":{"seq":12,"type":"response","request_seq":8,"command":"breakpointLocations","success":true,"body":{"breakpoints":[]}}},"level":0}
{"tag":"dap.send","timestamp":1620056709862,"metadata":{"connectionId":0,"message":{"seq":13,"type":"response","request_seq":9,"command":"breakpointLocations","success":true,"body":{"breakpoints":[]}}},"level":0}
{"tag":"dap.send","timestamp":1620056713130,"metadata":{"connectionId":0,"message":{"seq":14,"type":"event","event":"output","body":{"category":"telemetry","output":"js-debug/dap/operation","data":{"errors":[],"initialize":{"operation":"initialize","totalTime":1.8,"max":1.8,"avg":1.8,"stddev":null,"count":1,"failed":0},"!initialize.errors":[],"setBreakpoints":{"operation":"setBreakpoints","totalTime":26.4,"max":26.4,"avg":26.4,"stddev":null,"count":1,"failed":0},"!setBreakpoints.errors":[],"setExceptionBreakpoints":{"operation":"setExceptionBreakpoints","totalTime":0.6,"max":0.6,"avg":0.6,"stddev":null,"count":1,"failed":0},"!setExceptionBreakpoints.errors":[],"configurationDone":{"operation":"configurationDone","totalTime":0.6,"max":0.6,"avg":0.6,"stddev":null,"count":1,"failed":0},"!configurationDone.errors":[],"threads":{"operation":"threads","totalTime":0.6,"max":0.6,"avg":0.6,"stddev":null,"count":1,"failed":0},"!threads.errors":[],"launch":{"operation":"launch","totalTime":1496.9,"max":1496.9,"avg":1496.9,"stddev":null,"count":1,"failed":0},"!launch.errors":[],"loadedSources":{"operation":"loadedSources","totalTime":1.2,"max":1.2,"avg":1.2,"stddev":null,"count":1,"failed":0},"!loadedSources.errors":[],"breakpointLocations":{"operation":"breakpointLocations","totalTime":1.2,"max":0.7,"avg":0.6,"stddev":0.1,"count":2,"failed":0},"!breakpointLocations.errors":[]}}}},"level":0}
{"tag":"dap.receive","timestamp":1620056718481,"metadata":{"connectionId":0,"message":{"command":"disconnect","arguments":{"restart":false},"type":"request","seq":10}},"level":0}
{"tag":"dap.send","timestamp":1620056718996,"metadata":{"connectionId":0,"message":{"seq":15,"type":"event","event":"output","body":{"category":"stderr","output":"Debugger listening on ws://127.0.0.1:58540/b1e69957-0b11-49aa-92e5-8cc736ffa343\r\nFor help see https://nodejs.org/en/docs/inspector\r\n"}}},"level":0}
{"tag":"dap.send","timestamp":1620056719005,"metadata":{"connectionId":0,"message":{"seq":16,"type":"event","event":"output","body":{"category":"stderr","output":"Process exited with code 1\r\n"}}},"level":0}
{"tag":"dap.send","timestamp":1620056719006,"metadata":{"connectionId":0,"message":{"seq":17,"type":"event","event":"terminated","body":{}}},"level":0}
{"tag":"dap.send","timestamp":1620056719006,"metadata":{"connectionId":0,"message":{"seq":18,"type":"response","request_seq":10,"command":"disconnect","success":true,"body":{}}},"level":0}
connor4312 commented 3 years ago

It looks like you're using a very old Node version that has been end of life since 2018. Please try a more recent Node.js version -- the latest is 16.0.0.

Nickk4 commented 3 years ago

Yes, thank you, updating to node 14.15.1 solved it!