macosnode.jscocoabackground-processactivity-monitor

Background process shows as "not responding" on OS X


I'm attempting to resolve this weird problem with our OS X application.

As part of it's normal operation, it starts a long running background process — specifically a Web server, written in node.js.

After some time running, the background process shows up in the activity monitor as "Not Responding".

It's still functioning normally though, responding to requests from the web browser and not eating a high percentage of CPU or anything.

I would like to understand what exactly might be causing this status to be displayed, since it's not even a GUI application in the first place. What exactly does OS X use to determine if a command line application is not responding, if it doesn't have a Cocoa event loop?

Is it possible to flag it somehow as a background process so that the system does not query it for responses?

Thanks in advance.

Update: Just checked, the same seems to happen when launching the task from the command line. What makes a background app "Not respond" on the activity monitor?


Solution

  • Okay so as sergio pointed out in his comment, it was indeed something specific to Node.JS.

    The dev responsible for Node.JS portion of our app was able to trace back the source of the problem to the usage of the process.title property in Node.JS.

    It looks like the implementation of process.title in libuv does a lot of Core Foundation tricks to set the process title, so these are probably getting the process flagged as a GUI app by whatever heuristics the Activity Monitor uses to tell Cocoa apps apart from CLI apps.

    We have filed a bug report on libuv about this, but for now we're skipping process.title as simply setting it causes the server to show up as "not responding" on the Activity Monitor after a couple minutes.

    Update: This is now fixed in libuv as of this commit. It still hasn't propagated to a node release yet.