Webstorm Nodejs Debugger just executing but not stopping for the breakpoints Follow
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.
Please sign in to leave a comment.
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
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.
Path Mappings - Remote server root nodejs project folder
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.
> 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
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.
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.
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
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 ??
Please do something, I don't think it's a major issue, Please.
>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?
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 ??
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
I am going to run my NodeJs server locally and will tell you if debugging is happening correctly or not :)
thank you, please keep me posted:)
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
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?
generated code- do you mean to add breakpoints before running my app in debug mode ?
>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
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?
I used https://nodejs.org/api/debugger.html and It worked :) What can be the error in Webstorm?
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.
Now when I am hovering over this debugger line It is showing `undefined`.
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
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)
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
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
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 ?
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
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.
Is the debugger attached? What command do you use to start your server?
Server is already running and I ran it by debugging my app.js through Webstorm IDE.