-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
"Debug: Attach to Node Process" + sourceMapPathOverrides #94300
Comments
In tomorrow's nightly of our new debugger (when installed, it will register a command "debug.javascript.pickAndAttachOptions": {
"sourceMapPathOverrides": {
"webpack:///./*": "${workspaceRoot}/subfolder/*",
}
} Let us know if you run into any more issues! (Versifiers: easiest way to test is add this option with |
Oh wow, I thought I'm in some edge case and a few hours later, this issue is fixed 😄. Workspace setting sounds great, and what you suggest in vercel/next.js#10807 (comment), i.e., being able to detect path mappings automatically with the help of |
@connor4312 Actually one point to the solution mentioned above: Our monorepo has several Next.js projects in subfolders, like this:
So having a single path mapping probably will help only partially – in some README, I'll probably need to suggest that the person debugging should update Again, if |
We already use lsof when it's available 🙂 But right now it's only used when there's 0 or >= 2 workspace folders open--if there's exactly one open folder, we use that as the process cwd. As of microsoft/vscode-js-debug#326, for normal launches we set the cwd based on the nearest package.json-containing folder. Maybe we can adjust our attachment algorithm to do the same--if lsof is available, use the nearest package.json-containing folder inside any workspace folder. For Node.js, sourcemap resolution happens relative to the working directory, so that should work here, I think. microsoft/vscode-js-debug#413, should get to it early next week |
That sounds great indeed. If I understand correctly, the attach would detect |
Yep, that's right. |
To verify:
|
@JacksonKearl the log should be in the "debug console" view, rather than the terminal. |
I think that's intended behavior (cc @isidorn) so that you don't lose previous logs if you run a new launch config. (I see the same thing, but with an "Extension Host" entry since that happens to be the last thing I debugged). |
Yes this is designed behavior. |
Debug: Attach to Node Process is an awesome feature – no need to update npm scripts with
--inspect
and, most of the time, no need to createlaunch.json
configs.However, I'm in a situation where I'm trying to debug a Node.js project in a subfolder in my workspace. So in a console, I do:
VSCode can successfully attach to the process but all paths are broken – the debugger sends paths like
src/server.ts
but VSCode should interpret this assubfolder/src/server.ts
.If I started the process via
launch.json
(which I generally don't like too much – it duplicates a few things frompackage.json
, not all team members are using VSCode, etc.), this would work:I just learned today about
sourceMapPathOverrides
and it makes VSCode work, however, I'd really much prefer to be able to do Debug: Attach to Node Process and still somehow tell VSCode to apply a custom mapping.The text was updated successfully, but these errors were encountered: