Node.js and Socket.io become unresponsive

I have a relatively simple chat-type application running on Node.js and Socket.io. The node server streams chat data from a Minecraft server and then streams this to any clients connected on the website using Socket.io. A working demo of the system can be found here: standardsurvival.com/chat.

It works decently fine for the most part, but every once in a while the node server stops responding and active connections die shortly thereafter. The process will start consuming 100% CPU during this time but memory always stays relatively constant, so I'm doubting any sort of memory leak is involved.

It's been super frustrating as I haven't been able to reproduce the issue consistently enough to figure out what the problem is, and I don't know where to look. I've been setting up loops and commenting out various parts of the pipeline between the node server and website to try and pinpoint what may be causing it. No luck as of yet.

The code behind this system can be found here and here.

Any ideas?

Well I ended up figuring out what the problem was. A library I'm using was opening net.Sockets for standard HTTP requests to the Minecraft server, but was never actually closing them. Apparently the "end" event was never called when the request finished. So eventually all available file handles for the process were being used up and causing new requests to outright fail, which made the server appear to stop responding. I would have found this out sooner if I logged this error. Lesson learned.

I added a timeout to all sockets to fix this at least temporarily. Now the server has been running for days without a single issue :)