Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[node-debugger] Debugger spams "Could not read sourcemaps" messages #102042

Closed
manuth opened this issue Jul 9, 2020 · 20 comments
Closed

[node-debugger] Debugger spams "Could not read sourcemaps" messages #102042

manuth opened this issue Jul 9, 2020 · 20 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded

Comments

@manuth
Copy link
Contributor

manuth commented Jul 9, 2020

  • VSCode Version: 1.47.0-insider (system setup)
  • OS Version: Windows_NT x64 10.0.19041

Steps to Reproduce:

  1. Add a dependency which has .js-files containing //# sourceMappingURL=[...]
  2. Make sure the dependencies do not contain source-maps
  3. Run the node-debugger

Does this issue occur when all extensions are disabled? Yes

Expected behavior
Just like in the previous version of VSCode, missing source-map files should not be reported (should they...?).

Actual behavior
VSCode reports an error for every missing source-map files (even the ones inside the node_modules folder). This makes reviewing mocha debug sessions quite hard.

Screenshot

image

@connor4312
Copy link
Member

Thanks for the issue, this message was added in microsoft/vscode-js-debug#483, and matches what happens in the web browser if Chrome fails to resolve sourcemaps. (However, in Chrome you can toggle these messages, where our debug console has no such control.)

You can configure whether we resolve sourcemaps by specifying the new resolveSourceMapLocations option, e.g. this will disable resolution in node_modules:

"resolveSourceMapLocations": [
  "${workspaceFolder}/**",
  "!**/node_modules/**"
],

👍 this comment/issue if you'd like a setting to toggle off these messages.

@connor4312 connor4312 self-assigned this Jul 9, 2020
@connor4312 connor4312 added debug Debug viewlet, configurations, breakpoints, adapter issues under-discussion Issue is under discussion for relevance, priority, approach labels Jul 9, 2020
@connor4312 connor4312 added this to the On Deck milestone Jul 9, 2020
@manuth
Copy link
Contributor Author

manuth commented Jul 9, 2020

@connor4312 thank you very much for the rapid answer! 😄
Should I copy this issue over to microsoft/vscode-js-debug?

@connor4312
Copy link
Member

It's good here. I'll direct people to it as needed 🙂

@manuth
Copy link
Contributor Author

manuth commented Jul 10, 2020

@connor4312 I, btw, just gave it a go before - your recommended configuration works like a charm!
Though, it looks like the json-schema isn't up to date yet, as I receive a Property resolveSourceMapLocations is not allowed. when adding this to my configuration.

Instead of having an option to disable source-map messages I'd prefer to have these messages disabled for node_modules by default.

@connor4312
Copy link
Member

Currently, the old debuggers are "forwarding" the request to the new debugger (microsoft/vscode-js-debug#548). They don't know about the new options, but will pass them through. You can change the debug type to pwa-node to go directly to the new debugger.

@connor4312
Copy link
Member

We've had quite a few people opening issues about this.

The root problem is not the spam, but errors about files you don't care about. If a source map failed for a file you did expect to debug, it would not be desirable to hide that information. I think it's reasonable to just disable sourcemaps within node_modules by default; if users need them, they can configure the resolveSourceMapLocations to remove that exclusion.

@connor4312 connor4312 added bug Issue identified by VS Code Team member as probable bug and removed under-discussion Issue is under discussion for relevance, priority, approach labels Jul 10, 2020
@connor4312 connor4312 modified the milestones: On Deck, July 2020 Jul 10, 2020
@manuth
Copy link
Contributor Author

manuth commented Jul 10, 2020

@connor4312 Is the "${workspaceFolder}/**", part necessary?
I've noticed, that this default value causes issues when running debug-tasks in multi-root workspaces with resolveSourceMapLocations left undefined.

@connor4312
Copy link
Member

connor4312 commented Jul 10, 2020

Something there is. If the locations list is left at null, we'll resolve all sourcemaps without checking paths. With it specified, we require the sourcemap to match one of the patterns.

But one alternative closer to parity is to set it to **, omitting workspaceFolder, which will match all paths (unless they're later excluded). Updated the default in js-debug to that.

@samdoeswork
Copy link

I also experienced this issue and can verify the fix. I would strongly consider making this setting the default

@connor4312
Copy link
Member

connor4312 commented Jul 10, 2020

Thanks for the feedback. It will be the default on the upcoming nightly build. I will also aim to get this in the upcoming recovery release.

@connor4312 connor4312 added the candidate Issue identified as probable candidate for fixing in the next release label Jul 10, 2020
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Jul 13, 2020
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Jul 13, 2020
@pyuyu
Copy link

pyuyu commented Jul 14, 2020

"resolveSourceMapLocations": [
"${workspaceFolder}/",
"!
/node_modules/**"
],

Where should I put the configuration?

@manuth
Copy link
Contributor Author

manuth commented Jul 14, 2020

"resolveSourceMapLocations": [
"${workspaceFolder}/",
"!
/node_modules/**"
],

Where should I put the configuration?

Into your launch.json file as seen here:
https://github.com/manuth/NPMPackageEditor/blob/1564214c0d4a5dbf9b377218eb54edeaddf2fb3c/.vscode/launch.json#L15-L18

Keep in mind to change the type-property to pwa-node as mentioned by @connor4312

@hinojosachapel
Copy link

@manuth Thanks, buddy! Works like a charm.

@CTownsdin
Copy link

CTownsdin commented Jul 14, 2020

in launch.json,

"type": "pwa-node",
"resolveSourceMapLocations": [
    "${workspaceFolder}/**",
    "!**/node_modules/**"
]

AND restart vscode, and it's solved.

@pyuyu
Copy link

pyuyu commented Jul 15, 2020

"resolveSourceMapLocations": [
"${workspaceFolder}/",
"!
/node_modules/**"
],

Where should I put the configuration?

Into your launch.json file as seen here:
https://github.com/manuth/NPMPackageEditor/blob/1564214c0d4a5dbf9b377218eb54edeaddf2fb3c/.vscode/launch.json#L15-L18

Keep in mind to change the type-property to pwa-node as mentioned by @connor4312

{
  "configurations": [
    {
      "type": "pwa-node",
      "request": "attach",
      "name": "Attach by Process ID",
      "processId": "${command:PickProcess}",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "resolveSourceMapLocations": [
        "${workspaceFolder}/**",
        "!**/node_modules/**"
      ],
    }
  ]
}

this is my launch.json, it doesn't work

@connor4312
Copy link
Member

@pyuyu can you capture a trace log using these instructions?

If you're able to, add "trace": true to your launch.json and reproduce the issue. The location of the log file on your disk will be written to the Debug Console. Share that with us.

⚠️ This log file will not contain source code, but will contain file paths. You can drop it into https://microsoft.github.io/vscode-pwa-analyzer/index.html to see what it contains. If you'd rather not share the log publicly, you can email it to connor@xbox.com

@connor4312
Copy link
Member

Verification steps:

  1. Install typescript
  2. Add require("typescript"); debugger; to a Node.js file
  3. Verify that when you run it, you aren't blasted with Could not read sourcemaps messages

@roblourens roblourens added the verified Verification succeeded label Jul 16, 2020
@pyuyu
Copy link

pyuyu commented Jul 16, 2020

Verification steps:

  1. Install typescript
  2. Add require("typescript"); debugger; to a Node.js file
  3. Verify that when you run it, you aren't blasted with Could not read sourcemaps messages

there is no more Could not read sourcemaps, however the breakpoint didnt stop at the position where set,but stop at the file compiled by Babel

@connor4312
Copy link
Member

You may be hitting #102152. If not, please capture a trace log using the instructions I sent you.

@pyuyu
Copy link

pyuyu commented Jul 16, 2020

You may be hitting #102152. If not, please capture a trace log using the instructions I sent you.

thanks a lot, set debug.javascript.usePreview: false is worked for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

7 participants