microsoft / vscode-js-debug

A DAP-compatible JavaScript debugger. Used in VS Code, VS, + more
MIT License
1.66k stars 276 forks source link

Node.js paths on macOS are case sensitive #1682

Open Jack-Works opened 1 year ago

Jack-Works commented 1 year ago

Describe the bug Cannot find source map.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://github.com/microsoft/TypeScript
  2. Run npx hereby watch-min
  3. Use the following launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Mocha Tests (currently opened test)",
            "runtimeArgs": ["--nolazy"],
            "program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
            "args": [
                "-u",
                "bdd",
                "--no-timeouts",
                "--colors",
                "built/local/run.js",
                "-f",
                // You can change this to be the name of a specific test file (without the file extension)
                // to consistently launch the same test
                "${fileBasenameNoExtension}",
                "--skip-percent",
                "0"
            ],
            "env": {
                "NODE_ENV": "testing"
            },
            "outFiles": [
                "${workspaceFolder}/built/**/*.js",
                "${workspaceFolder}/built/**/*.mjs",
                "${workspaceFolder}/built/**/*.cjs",
                "!**/node_modules/**"
            ],
            "sourceMaps": true,
            "smartStep": true,
            "preLaunchTask": "npm: build:tests",
            "console": "integratedTerminal",
            "customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
        },
        {
            // See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
            "type": "node",
            "request": "attach",
            "name": "Attach to VS Code TS Server via Port",
            "customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
            "sourceMaps": true,
            "outFiles": ["${workspaceFolder}/built/local/*.js", "!**/node_modules/**"],
            "enableTurboSourcemaps": true,
            "port": 5667,
            "trace": true
        },
        {
            "type": "node",
            "name": "Launch VSCode",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": ["--user-data-dir=${workspaceFolder}/.vscode/.vscode-debug", "${workspaceFolder}/../"],
            "env": {
                "TSS_DEBUG": "5667",
                "NODE_ENV": "development"
            }
        }
    ]
}

Start VSCode and then attach to the language service.

Log File

vscode-debugadapter-cff4305c.json.gz

I found there is something strange happened in the logfile:

image

Version: 1.77.3 (Universal) Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710 Date: 2023-04-12T09:19:37.325Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Darwin arm64 22.4.0 Sandboxed: No

JavaScript Debugger (Nightly) v2023.4.1317

connor4312 commented 1 year ago

Functional duplicate of https://github.com/microsoft/vscode-js-debug/issues/1646

Jack-Works commented 1 year ago

@connor4312 I'm using the latest nightly version and still have this problem. are you sure it's the same problem?

connor4312 commented 1 year ago

Can you confirm what version of nightly you're running? THere was an issue in our pipelines that prevented it getting published for a little while

Jack-Works commented 1 year ago

Can you confirm what version of nightly you're running? THere was an issue in our pipelines that prevented it getting published for a little while

I tried v2023.4.2817

Jack-Works commented 1 year ago

I tried chrome devtools and it can bind breakpoint.

Jack-Works commented 1 year ago

ok, I figured out why. It's about the case-insensitive file system (macOS default).

I started the program with TypeScript/built/local, but I use typescript/ to develop, therefore ${workspaceFolder}/built/local becomes typescript/built/local and mismatched with the started program.

cc @connor4312 can you open the issue? although I have already fixed the problem by making the file casting consistent.

justingrant commented 1 year ago

I think I just hit this bug (also on MacOS) in a much simpler case without any source maps or transpilation, just a simple node foo.mjs command.

Node ran the file (and debugger statements broke into the debugger) but breakpoints weren't bound.

Here's my config, in case it's helpful:

    {
      "name": "validstrings.mjs",
      "request": "launch",
      "type": "node",
      "runtimeArgs": ["polyfill/test/validstrings.mjs"],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "autoAttachChildProcesses": true,
      "skipFiles": [
        "<node_internals>/**",
        "**/node_modules/**"
      ]
    },

Once I fixed the filename to the actual "validStrings.mjs" (capital S) then it worked great.