Skip to content

fix(core): ensure perf logs are flushed before exit in graph command#33621

Merged
FrozenPandaz merged 4 commits intomasterfrom
fix-graph-logging
Nov 28, 2025
Merged

fix(core): ensure perf logs are flushed before exit in graph command#33621
FrozenPandaz merged 4 commits intomasterfrom
fix-graph-logging

Conversation

@FrozenPandaz
Copy link
Copy Markdown
Contributor

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 createDependencies appear.

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.ts file had process.exit(0) calls that terminated the process immediately, not giving the async PerformanceObserver callback time to fire.

Added await new Promise((res) => setImmediate(res)) before process.exit(0) to give the event loop one tick to process pending callbacks. This follows the existing
pattern in show/projects.ts and show/project.ts.

Add setImmediate promise before process.exit() to give the
PerformanceObserver callback time to fire when NX_PERF_LOGGING is enabled.
@FrozenPandaz FrozenPandaz requested a review from a team as a code owner November 25, 2025 22:09
@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Nov 28, 2025 2:42pm

@netlify
Copy link
Copy Markdown

netlify Bot commented Nov 25, 2025

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 60db0e0
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6929b372c9c0020008991ab3
😎 Deploy Preview https://deploy-preview-33621--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Nov 25, 2025

View your CI Pipeline Execution ↗ for commit 60db0e0

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 46m 38s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2m 44s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 12s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-28 15:27:45 UTC

Comment on lines 480 to 481
});
process.exit(1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Suggested change
});
process.exit(1);
await new Promise((res) => setImmediate(res));
process.exit(1);

Spotted by Graphite Agent

Fix in Graphite


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]
nx-cloud[bot]

This comment was marked as outdated.

Add setImmediate promise before process.exit() to give the
PerformanceObserver callback time to fire when NX_PERF_LOGGING is enabled. [Self-Healing CI Rerun]
Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we reran your CI automatically.

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@FrozenPandaz FrozenPandaz merged commit 191e492 into master Nov 28, 2025
19 checks passed
@FrozenPandaz FrozenPandaz deleted the fix-graph-logging branch November 28, 2025 15:28
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 4, 2025

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Dec 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants