microsoft / vscode-js-debug

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

sourceURL containing space does not work #2089

Closed sapphi-red closed 1 month ago

sapphi-red commented 1 month ago

Describe the bug When // #sourceURL= has an URL containing space, the transformed file is shown instead of the original file.

To Reproduce Steps to reproduce the behavior:

  1. Clone https://github.com/ondrejrohon/sveltekit-debug-vscode in a path containing a whitespace (e.g. C:\Users\green\foo bar\sveltekit-debug-vscode)
  2. Click this button image
  3. Open http://localhost:5173
  4. See the transformed file (IIFE named anonymous) is shown instead of the original file (ESM exporting load function). image

Log File vscode-debugadapter-e6485847.json.gz

VS Code Version: 1.93.1

Additional context It did not work even if I escaped the space with %20.

Original issue: https://github.com/vitejs/vite/issues/17977, https://github.com/sveltejs/kit/issues/12625

connor4312 commented 1 month ago

The string you put in there is not a valid URL. File URLs should generally begin with file:///. Encoding it as a URL properly will allow for escaping of spaces.

This is not a behavior controlled by the debugger, source URL parsing happens in V8/Chrome and in your case it's not parsing correctly:

{
  "method": "Debugger.scriptParsed",
  "params": {
    "scriptId": "1215",
    "url": "",
    "startLine": 0,
    "startColumn": 0,
    "endLine": 14,
    "endColumn": 2,
    "executionContextId": 1,
    "hash": "d9e778e08830bd227d1eaf933031d1e1836746f0ee5975a848444afccff251d0",
    "executionContextAuxData": {
      "isDefault": true
    },
    "isLiveEdit": false,
    "sourceMapURL": "<data source map url>",
    "hasSourceURL": false, // <-
    "isModule": false,
    "length": 1181,
    "stackTrace": {
      "callFrames": [
        {
          "functionName": "instantiateModule",
          "scriptId": "215",
          "url": "file:///C:/Users/green/Downloads/foo%20bar/sveltekit-debug-vscode-main/node_modules/vite/dist/node/chunks/dep-CDnG8rE7.js",
          "lineNumber": 52905,
          "columnNumber": 23
        }
      ]
    },
    "scriptLanguage": "JavaScript",
    "embedderName": ""
  }
}
sapphi-red commented 1 month ago

Thanks for the response!