Search code examples
javascriptnode.jsserverprocessdbus

What is dbus-daemon used for by nodejs?


I created a nodejs server app that is using a few modules like ssh2, child_process, puppeteer, ws, sqlite, and when this app runs I see a "dbus-daemon" process with message+ as user that makes CPU usage rise logarithmically in a period of a few days to 100% making the entire server unresponsive.

Does anyone know why would nodejs use this process for? In the app I am spawning a few child processes that communicate with each other via message events. Could that be the reason? Because dbus is apparently a messaging system

My app itself does not hog CPU because I am monitoring it with PM2 and it's always under 5%. But for some reason it makes this dbus thing consume cpu


Solution

  • As Ouroborus stated in the question comments, dbus is used for inter-process communication.Your initial idea that something in your app is firing these up is highly probable. Running within a clean linux environment such as a lightweight dedicated container will exclude the origin to be from system; namely the system-wide dbus daemon instance. Leaving your app and its dependencies to investigate.

    Depending on what linux environment you are using, you can monitor dbus processes - but from your question I understand you have already checked. If that only points to your app, then I'm quite certain that one of your dependencies/packages is causing the issue. I've had a similar issue with a system daemon being autolaunched again and again due to an older package I was using (that had no check for existing instances).

    Try updating all your packages/dependencies or else removing them temporarily in batches to find the trouble maker.

    There is a small change that you can also resolve the issue by specifying the DBUS_SESSION_BUS_ADDRESS variabele (a quick search on howto for your enviro). If this variable is unset, it is possible that a process will attempt to invoke dbus-launch with the --autolaunch option to start up a new session bus. And if it keep losing track of it's open session busses, it will keep launching new ones.