fix(core): ensure perf logs are flushed before exit in graph command#33621
fix(core): ensure perf logs are flushed before exit in graph command#33621FrozenPandaz merged 4 commits intomasterfrom
Conversation
Add setImmediate promise before process.exit() to give the PerformanceObserver callback time to fire when NX_PERF_LOGGING is enabled.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ 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 60db0e0
☁️ Nx Cloud last updated this comment at |
| }); | ||
| process.exit(1); |
There was a problem hiding this comment.
Performance logs will not be flushed before this error exit. The pattern await new Promise((res) => setImmediate(res)) is added before process.exit(0) at lines 398 and 483, but is missing before this process.exit(1). This creates an inconsistent exit behavior where error paths don't flush performance logs.
To fix, add the same pattern before the exit:
await new Promise((res) => setImmediate(res));
process.exit(1);| }); | |
| process.exit(1); | |
| await new Promise((res) => setImmediate(res)); | |
| process.exit(1); |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
Add setImmediate promise before process.exit() to give the PerformanceObserver callback time to fire when NX_PERF_LOGGING is enabled. [Self-Healing CI Rerun]
Add setImmediate promise before process.exit() to give the PerformanceObserver callback time to fire when NX_PERF_LOGGING is enabled. [Self-Healing CI Rerun]
There was a problem hiding this comment.
Nx Cloud has identified a flaky task in your failed CI:
🔂 Since the failure was identified as flaky, we reran your CI automatically.
🎓 Learn more about Self-Healing CI on nx.dev
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
When running
NX_PERF_LOGGING=true nx graph --file graph.json, many performance logs are missing (e.g.,create-project-graph-async,retrieve-project-configurations).Only plugin-specific logs like
createDependenciesappear.Expected Behavior
All performance timing logs should appear, matching the output of
NX_PERF_LOGGING=true nx show projects.Related Issue(s)
N/A - Internal improvement for debugging/profiling.
Solution
The
graph.tsfile hadprocess.exit(0)calls that terminated the process immediately, not giving the asyncPerformanceObservercallback time to fire.Added
await new Promise((res) => setImmediate(res))beforeprocess.exit(0)to give the event loop one tick to process pending callbacks. This follows the existingpattern in
show/projects.tsandshow/project.ts.