fix(core): commands shouldn't hang when passing --help#34506
fix(core): commands shouldn't hang when passing --help#34506FrozenPandaz merged 3 commits intomasterfrom
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 303e102
☁️ Nx Cloud last updated this comment at |
253782e to
bb154cc
Compare
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:
Our investigation shows these e2e test failures are due to a missing @microsoft/api-extractor module (ConsoleMessageId) in the test environment, which is unrelated to the PR's changes (process exit handling and daemon socket lifecycle). The failures occur in e2e test projects that were not modified by this PR, and there's no logical connection between help command fixes and API Extractor module resolution issues.
No code changes were suggested for this issue.
Trigger a rerun:
🎓 Learn more about Self-Healing CI on nx.dev
When running `nx show project --help` or similar commands that hit the help path in init-local.ts, the process would hang indefinitely. This is because yargs' built-in help is disabled (`.help(false)`) and the daemon client's socket connections keep the Node.js event loop alive. Adding `process.exit(0)` after `showHelp()` matches the pattern used by other commands (e.g., `init`) that already handle this correctly.
The main daemon client socket created in setUpConnection() was keeping the Node.js event loop alive after command completion, requiring every command handler to call process.exit() explicitly. By calling socket.unref(), the socket no longer prevents the process from exiting naturally. The existing keep-alive setTimeout in sendMessageToDaemon() ensures the process stays alive while actively awaiting daemon responses.
c1c20fd to
e0a692f
Compare
## Current Behavior `--help` on commands that hit yargs help are hanging ## Expected Behavior It doesn't hang. This contains a quick fix in adding the process.exit call, but also adds the unref needed to maintain previous working behavior. We'll need to investigate long term if additional areas keep commands alive, but adding this unref theoretically allows removing the process.exit calls from `nx show` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # --------- Co-authored-by: Jason Jean <jasonjean1993@gmail.com> (cherry picked from commit df8a2c4)
Current Behavior
--helpon commands that hit yargs help are hangingExpected Behavior
It doesn't hang. This contains a quick fix in adding the process.exit call, but also adds the unref needed to maintain previous working behavior. We'll need to investigate long term if additional areas keep commands alive, but adding this unref theoretically allows removing the process.exit calls from
nx showRelated Issue(s)
Fixes #