My understanding is that NodeJS runs until all the events are drained from the event queue, and then it will exit. On various occasions I have written a script, that uses third party modules and it does what I want it to do, but doesn't exit. I assume that's because some of the other third party modules have something in the event queue.
Is there anything I can do to watch the queue, encourage it to be drained, or even determine who still has something to do (and perhaps get enough information to know that if I process.exit anyway, no harm will be done)
Thanks for your suggestions.
Without access to those modules there is not very much you can do.
SetInterval will prevent your application of stopping, but you can call ClearInterval on those timers. Your challenge will be to manage those interval objects and perform cleaning if application needs to be removed.
One of hacky and straight forward solution would be to 'replace' SetInterval default method with bespoke that would register interval and act the same way as default from use point of view. That way then you will have ability to collect all interval handles easier.