Webstorm Nodejs Debugger just executing but not stopping for the breakpoints

I am using Webstorm and have added a remote server, now I am trying to debug my app and for that, I have added some breakpoints in some of my routes files and `app.js.

Now the thing happening is that all my static breakpoints(when my code is compiled) are executing and my debugger is stopping for them but after that when I call any of my code in my route file then the breakpoint there just get a tick mark(executes) but debugger didn't stop for that breakpoint. So because of that, I am not able to see any variable data at that breakpoint and it is happening every time and for all routes.

2
45 comments

Tick mark indicates that the breakpoint is 'resolved' (i.e. the source file breakpoint is set in has been found - from sourcemaps, etc.). If the checkmark is there, but execution is not suspended, this usually means that the line under breakpoint is not executed... If it's suspended, but on the wrong line, it must be a mapping issue.

Please can you elaborate on your problem? What run configuration do you use, what code are you trying to debug? Is it a code of your node.js server, or your client-side code? Screen recording that shows up the issue might be helpful

0
Avatar
Permanently deleted user

The static breakpoints get blue coloured with check marks and debugger stop for them, and dynamic breakpoints also gets check marks even when they didn't execute but they never get blue coloured line(debugger never stop for them).

Where are the Mapping files ??

Also, I am running my Nodejs Server on remote server instance(Google Cloud Virtual Machine), and I am trying to debug it in WIndows on the client side where my WebStorm is installed.

 

In Edit Configuration

Node Interpreter - Is set to sftp://username@IP:22/usr/bin/node

Working DIrectory - Is set to client root project directory.

Javascript FIle - app.js

Path Mappings - Remote server root nodejs project folder

In Deployments

Local Path - Set to my client root nodeJs project folder

Deployment Path on Server - Set to server root NodeJs project folder

 

I followed this tutorial https://www.youtube.com/watch?v=ngs4QAfuMCc 

 

Please Help me there is nothing I can do without debugging.

 

 

 

0

> dynamic breakpoints also gets check marks even when they didn't execute but they never get blue coloured line

 

can you clarify what you mean by dynamic breakpoints? Do you set them during debug session, not beforehand?

 

>Where are the Mapping files ??

it depends on your configuration

0
Avatar
Permanently deleted user

I add breakpoints both before and after running my app in debug mode. Dynamic means that they are not in app.js file they are present inside routing functions which will get called only when I will hit the routes.

0
Avatar
Permanently deleted user

Can you tell me what parameters or configs can I see inside Mappings file so that I can check where is the error. Please Help me.

0

generated sourcemaps are not human readable... You can only  check URLs there - but they seem to be correct, as files are resolved (there are checkmarks in the breakpoints). they can be resolved in a wrong way, but there is no way to see what's wrong unless you have a project to play with

0
Avatar
Permanently deleted user

My code project contains post routes only no web pages, will it cause any problem because when IDE will go to http://remoteserverurl then nothing will show as I have not put any web page/HTML in any of the URL ??

0
Avatar
Permanently deleted user

Please do something, I don't think it's a major issue, Please.

0

>My code project contains post routes only no web pages, will it cause any problem

 

no, it shouldn't cause any problems.

I can do nothing to help you unfortunately, as it's not clear what is going wrong.

Can you debug the same application locally (i.e. using local Node.js interpreter)? Can you share a project that shows up the issue?

0
Avatar
Permanently deleted user

Actually my server only listens to particular ports which I add them, can you tell me by debugging port is connected through which protocol?? tcp ??

0

WebStorm uses Chrome debugging protocol (https://chromedevtools.github.io/devtools-protocol/) to debug Node.js apps; this doesn't have any relation to the ports your server is listening on. And your issue is unlikely related to ports being used

0
Avatar
Permanently deleted user

I am going to run my NodeJs server locally and will tell you if debugging is happening correctly or not :)

1

thank you, please keep me posted:)

0
Avatar
Permanently deleted user

Same thing happening when I am trying to run locally then a made a url /homecoming where I am printing  a console log and have attached a breakpoint now console.log is printing and the breakpoint inside it is getting a red mark but debugger not stopping for it and line does not get blue coloured

 

0

One more thing to check: does the issue persist if you create breakpoints in the generated code instead of adding them to your source files?

0
Avatar
Permanently deleted user

generated code- do you mean to add breakpoints before running my app in debug mode ?

0

>do you mean to add breakpoints before running my app in debug mode ?

No - as, according to you, the issue occurs when adding breakpoints both before and after running app in debug mode.

I mean adding breakpoints to the code that is actually executed. You are compiling your app, right? then try adding breakpoints to compiled code, not to original one

1
Avatar
Permanently deleted user

Sorry but I have only tried debugging through IDE so don't know how to add them in the source code can you tell me any doc on it?

0
Avatar
Permanently deleted user

I used https://nodejs.org/api/debugger.html  and It worked :) What can be the error in Webstorm?

 

app.get('/homecoming', function(req, res) {
console.log('HomeComing');
debugger;
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
})
0
Avatar
Permanently deleted user

Don't know what but something strange is happening, when I first attached this `debugger` line the Webstorm stopped for it and the line turned blue, but now whenever I am putting debugger and then running my app again in the debug mode now IDE is not stopping on this `debugger` line.

0
Avatar
Permanently deleted user

Now when I am hovering over this debugger line It is showing `undefined`.

0

Sorry, but it seems that we are just wasting the time... Still I have no idea what your project looks like, so all my attempts to help you remain an exercise in guesswork.

As the issue can be recreated when debugging locally, this is clearly the problem with sourcemaps. But I can't track it down unless I have a project to play with

0
Avatar
Permanently deleted user

My bad Actually I was using Google Compute Engine as the remote server, and as per google docs I have attached the google-cloud debugger from the beginning because of which the IDE debugger was never getting attached, after commenting it debugging is happening correctly :) Thanks for the wonderful support and narrowing down the problem (y)

require('@google-cloud/debug-agent').start({ allowExpressions: true });
1
Avatar
Permanently deleted user

Just one thing to ask When I Terminate my Webstorm it closes the server remote server also. Can I have the functionality where whenever I close the project the server will not get closed, I thought of using forever package which I have also installed on my remote server and in interpreter path I tried to give path to forever which is "/usr/bin/forever" but then I got the below error 

 

0

Not sure if it helps, but I'd suggest choosing Disconnect (if available) as On closing tool window with running process value in Settings | Appearance & Behavior | System Settings

0
Avatar
Permanently deleted user

Now the server is not disconnecting, but now when I am opening my project again in Webstorm then if I run debug app then I am getting error "Error: listen EADDRINUSE :::3000", and if I not click on debug then how can I debug my app, is there any option to attach debugger to already running service or not ?

0

You need using Attach to Node.js/Chrome run configuration to attach to a running Node.js process. See https://www.jetbrains.com/help/webstorm/2018.1/running-and-debugging-node-js.html#remote_debugging

0
Avatar
Permanently deleted user

Thanks, actually I went through the doc and I clicked on "Attach to Node.js/Chrome" and then I specify IP of remote in host and port as the port on which my remote server is running. But nothing is printing in logs whereas my remote server is taking requests successfully.

0

Is the debugger attached? What command do you use to start your server?

0
Avatar
Permanently deleted user

Server is already running and I ran it by debugging my app.js through Webstorm IDE.

0

Please sign in to leave a comment.