-2

I have a express.js API that i recently had to tweak for some frankly dumb changes that affected core elements of it.

Now I have the problem that sometimes my server doesn't respond and after changing ~ 15 API paths i can no longer backtrack and redo it without losing way too much time. I suspect the server somehow is stuck in a endless loop and is just busy looping trough infinity and not responding to anything else.

Is there any good way to debug this kind of bug? Can i e.g. log the line-number i am running every second?

Clemens Himmer
  • 1,340
  • 2
  • 13
  • 26
  • Possible duplicate of [How do I debug Node.js applications?](http://stackoverflow.com/questions/1911015/how-do-i-debug-node-js-applications) – Num Lock Apr 13 '16 at 06:54
  • How would that help? Did you just google for "how to debug" and linked it here? If not, please explain how this would help me find the exact line i am stuck? When i read this article i could not see how it would help me. – Clemens Himmer Apr 13 '16 at 06:59
  • No, I did not simply google _how to debug_. From what you described, I strongly recommend you read up how debugging works and how it may help you. Have a look at profiling while you are at it. And maybe also start using version control. – Num Lock Apr 13 '16 at 07:06

2 Answers2

2

I used the Visual Studio debugger to be able to see the call stack and current line upon pausing the process.

Clemens Himmer
  • 1,340
  • 2
  • 13
  • 26
0

You can debug expressjs by setting the environment variable DEBUG

http://expressjs.com/en/guide/debugging.html

If you want to show all protocols express uses internally set the environment variable DEBUG to express:* when you start your application

$ DEBUG=express:* node index.js

or node-inspector (https://github.com/node-inspector/node-inspector), see this Node-inspector with Express 4

Community
  • 1
  • 1
ralf htp
  • 9,149
  • 4
  • 22
  • 34