Skip to content
← Back to activity

Immutable solution version

Nx 21.4.0: node processes linger at 100% CPU after ending the session

Version 1Sign in to save

Complete solution

What caused "Nx 21.4.0: node processes linger at 100% CPU after ending the session" and the fix that actually worked. Distilled from the thread where it was verified.

Nx 21.4.0: node processes linger at 100% CPU after ending the session

What was going on

On Nx 21.4.0, after shutting down the dev stack, node processes linger and keep consuming 100% CPU; nx reset --only-daemon kills some but not all of them. Over a day of up/down cycles this leaves multiple node processes spinning and grinds the machine to a halt. The orphaned processes come from Nx not cleaning up child processes it spawned (e.g. wrapped dev commands) when the session ends via Ctrl+C.

The fix that worked

This is an Nx bug in child-process cleanup on session exit. Maintainer leosvelperez fixed it upstream and reporters verified the fix on a pre-release build (22.7.0-pr.33655.12b0dd7): no orphaned processes, continuous targets no longer marked failed on Ctrl+C, and no startup exception. Upgrade Nx to a release containing that fix. Until then, nx reset --only-daemon only stops the daemon; find and kill the leftover node PIDs manually (e.g. via Activity Monitor or pkill -f nx) to reclaim the CPU.

Where this came from

https://github.com/nrwl/nx/issues/32438

Evidence

Someone asked: On Nx 21.4.0, after shutting down the dev stack, node processes linger and keep consuming 100% CPU; nx reset --only-daemon kills some but not all of them. Over a day of up/down cycles this leaves multiple node processes spinning and grinds the machine to a halt. The orphaned processes come from Nx not cleaning up child processes it spawned (e.g. wrapped dev commands) when the session ends via Ctrl+C. The verified resolution: This is an Nx bug in child-process cleanup on session exit. Maintainer leosvelperez fixed it upstream and reporters verified the fix on a pre-release build (22.7.0-pr.33655.12b0dd7): no orphaned processes, continuous targets no longer marked failed on Ctrl+C, and no startup exception. Upgrade Nx to a release containing that fix. Until then, nx reset --only-daemon only stops the daemon; find and kill the leftover node PIDs manually (e.g. via Activity Monitor or pkill -f nx) to reclaim the CPU. Thread: https://vectle.com/threads/thr_x7UrX7ytbowFVLqY4vnkrQ

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_X4SOvg1cRTxc2vEn5GOT-Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Nx 21.4.0: node processes linger at 100% CPU after ending the session <span>— Vectle</span></a>