Skip to content

vscode node debugger parses inline sourcemap incorrectly #35978

@t83714

Description

@t83714
  • VSCode Version: 1.17.0
  • OS Version: macOS 10.13

Steps to Reproduce:

  1. Create an empty folder
  2. Add package.json with the following content:
{
  "name": "vscode-issue",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@std/esm": "^0.11.3"
  },
  "@std/esm": {
    "esm": "all",
    "cjs": true
  }
}
  1. Create file index.js with the following content:
import path from "path";

console.log(path.resolve(__dirname, ".."));
  1. Configure launch.json as:
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}/index.js",
            "runtimeArgs": [
                "-r","@std/esm"
            ]
        }
    ]
}
  1. npm install
  2. Press F5 to start vscode debugger
  3. You will see the following error:
Debugging with inspector protocol because Node.js v8.6.0 was detected.
node --inspect-brk=36570 -r @std/esm index.js 
Debugger listening on ws://127.0.0.1:36570/a572c7ff-3251-4ae3-b74c-5abe01c3b73c
Debugger attached.
SourceMaps.getMapForGeneratedPath: exception while processing path: /Users/user/Development/vscode-issue/index.js, sourcemap: data:application/json;charset=utf-8,%7B%22version%22:3,%22sources%22:%5B%22/Users/user/Development/vscode-issue/index.js%22%5D,%22names%22:%5B%5D,%22mappings%22:%22AAAA;AACA;AACA%22%7D
SyntaxError: Unexpected token � in JSON at position 0
    at JSON.parse (<anonymous>)
    at new SourceMap (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug2/node_modules/vscode-chrome-debug-core/out/src/sourceMaps/sourceMap.js:20:25)
    at sourceMapContentsP.then.contents (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.node-debug2/node_modules/vscode-chrome-debug-core/out/src/sourceMaps/sourceMapFactory.js:53:28)
    at <anonymous>

Reproduces without extensions: Yes

It seems vscode debugger always assumes the inline sourcemap data URI is in base64 encoding (even if the ;base64 extension is not included in the data URI scheme).

This will lead to data decoding error.

Metadata

Metadata

Assignees

Labels

debugDebug viewlet, configurations, breakpoints, adapter issuesfeature-requestRequest for new features or functionalityverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions