GSC Thread Debugging
-
I’ve been learning GSC recently, and I’ve encountered an issue where my server crashes after ~8 hours, but the console doesn’t show any errors, and the heartbeat continues indefinitely.
I suspect that some threads in my scripts are not terminating properly and are slowly accumulating over time. Is there a way to debug open threads in GSC?
My first idea was to use a global counter to track active threads. I increment the counter when a thread starts, but I can’t find a way to guarantee decrementing the counter when a thread exits—since an endon() call might kill the thread before it reaches the decrement line.
For example:
init(){ level.thread_count = 0; level thread func(); } func(){ level.thread_count++; level endon("end"); // When called, the loop is killed and decrement line is never reached // infinite loop level.thread_count--; }
Maybe I'm on the completely wrong path, as I've double checked all of my threads have endon() calls, but there seems to be no error logs that can point me in any other direction.
-
Are you using plugins?