Debug startup code for a glitch app

I want to debug some of the start-up code for my glitch app when the require statements are running in the very beginning.

The problem is that by the time the debugger connects it is usually past all of those statements. Is it possible to have the debugger run with --inspect-brk like behavior so I can catch the code running at start?

Hey @rajsite as far as I know the debugger doesn’t support anything like that, but I’ll ask the rest of the team in case I’m missing something.

Typically when I’m trying to troubleshoot something in that portions of the app I resort to the log-and-inspect pattern.

Ok @rajsite I played around with this a little, and was able to gety to what you’re looking for by combining debugger; and sleep. I added this to the top of my entrypoint file:

var sleep = require('sleep'); 
sleep.sleep(30);
debugger;

This is only lightly tested, and you might need to play around with the sleep time, and by default the request will time out after ~60 seconds in my experience, but otherwise using this and then sending a refresh in the project console will get you a debugger stopped on the debugger; line.

Hope this helps!

1 Like

Haven’t tried it yet, but I’ll keep it in mind the next time it comes up! Thanks!