microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.67k stars 29.06k forks source link

Cannot set breakpoints in Meteor builds of node server app #22818

Closed brucejo75 closed 7 years ago

brucejo75 commented 7 years ago

I connected with @weinand, on my stackoverflow posting. Adding issue as requested.

Steps to Reproduce:

  1. in VS Code: configure launch.json attach:
    {
    "name": "Attach to Server",
    "type": "node",
    "request": "attach",
    "port": 5838,
    "address": "localhost",
    "restart": true,
    "timeout": 20000,
    "sourceMaps": true,
    "protocol": "legacy",
    "outFiles": ["${workspaceRoot}/meris/.meteor/local/build/programs/server/**/*.js"]
    }
  2. in CMD Shell: set NODE_OPTIONS environment variable set NODE_OPTIONS=--debug=5838
  3. in CMD Shell: start meteor: meteor
  4. in VS Code: set a breakpoint on a source file clicking in far left column and get bright red indicator.
  5. in VS Code: attach to the process. Successfully attaches
  6. in webapp (connected to server): execute function that will execute code where breakpoint is set.

Result:

Does not stop debugger at breakpoint set in my source file.

Other observations:

"meteor://💻app/server/main.js"

It looks a little odd to me... what is with this 💻 character?

Comments

brucejo75 commented 7 years ago

Hi @weinand, @roblourens, any update on this? Thanks!

roblourens commented 7 years ago

Meteor writes sourcemaps with fake meteor:// paths that the legacy node debugger has trouble resolving to files on disk. Your best shot is probably

brucejo75 commented 7 years ago

Thanks @roblourens, any thoughts on why node-inspector is able to handle the fake meteor:// paths? I am writing an issue for the meteor folks and want to make sure I understand this.

Thanks!

roblourens commented 7 years ago

Because it doesn't need to map the paths to files on disk, which is the hard part. It just takes them as is.

brucejo75 commented 7 years ago

Got it! Thanks @roblourens!

teknologist commented 7 years ago

Hi @roblourens Strange thing here....

If I open node-inspector (I mean http://localhost:8080/?port=5858 in Chrome) once, then I can put break points on vscode (I have VSCode connected to 5959 in legacy mode) and have it stop there and show debug infos, that is even after closing the node-inspector window completely.

I just need to open http://localhost:8080/debug once, let it load everything and the close it.

What do you think ?

Many thanks in advance

roblourens commented 7 years ago

Sure, that could work. The app will be in debug mode even when node-inspector is detached. I'm not sure what you're asking.

teknologist commented 7 years ago

Hi @roblourens

What I am saying is that if I just launch vscode and attach , no breakpoints work.

now if I just launch node-inspector once, let it load then close the window, I go back to VSCode and everything works. I can set breakpoints IN VSCode and I don't need to leave node-inspector open.

So basically I just need to launch node-inspector once at the start of the debugging session and close it immediately (I don't need to keep it open, nor I need to set breakpoints or anything in it))... Then I can work debugging in VSCode for as long as I want.

Previously I didn't need to launch node-inspector at all, it would work out of the box from VSCode.

Hope I am making myself clearer this time....

roblourens commented 7 years ago

I see. Can you open a new issue for that? Sounds like it's not related to this one.

matthova commented 7 years ago

@teknologist did you make a new issue for this? I'm interested as well.

teknologist commented 7 years ago

@matthova Haven't had the time. but I can confirm, I can only set breakpoints in Node inspector. As soon as I set them in NodeInspector , VSCode stops at the breakpoints and the debug IDE works fine. Breakpoints set in VSCode are plainly ignored.

Feel free to open an issue.