fix(core): release per-run process listeners and task history results - #36866
fix(core): release per-run process listeners and task history results#36866AgentEnder wants to merge 1 commit into
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 33b55c8
☁️ Nx Cloud last updated this comment at |
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx create-nx-workspace@23.2.0-pr.36866.449f6f3 my-workspaceOr just copy this version and use it in your own command: 23.2.0-pr.36866.449f6f3
To request a new release for this pull request, mention someone from the Nx team or the |
3ce7fc7 to
12868de
Compare
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 triggered a CI rerun by adding an empty commit to this branch.
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
The DTE agent path creates a TaskOrchestrator per runDiscreteTasks call in one long-lived process. Each orchestrator registered SIGINT/SIGTERM/SIGHUP handlers (plus the forked runner's message/exit handlers) that closed over the orchestrator and were never removed, pinning the task hasher (including the native project-graph copy), lifecycles, and every TaskResult with its full terminalOutput — showing up as unbounded RSS growth on Nx Cloud agents (~1x each task's stdout plus per-batch fixed costs, permanently, per assignment batch). - TaskOrchestrator.dispose() removes the signal handlers and the forked runner's process listeners; called at the end of run(), after runDiscreteTasks results settle, and after continuous tasks exit - TaskHistoryLifeCycle.pendingResults (a process-lifetime singleton) no longer retains terminalOutput and is cleared in endCommand()
b36907e to
33b55c8
Compare
Current Behavior
Every
runDiscreteTaskscall registers SIGINT/SIGTERM/SIGHUP handlers (plus the forked runner's message/exit handlers) that are never removed. Each closes over its orchestrator, so a long-lived process like an Nx Cloud agent retains every orchestrator it ever created: the task hasher (with its native project-graph copy), the lifecycles, and every task result with full terminal output.TaskHistoryLifeCycle.pendingResultsalso keeps everyTaskResultfor the life of the process. A profiled customer agent grew from 237MB to 5.5GB over 50 tasks.Expected Behavior
Process listeners are removed once a run completes, task history stops retaining terminal output, and agent memory stays flat across assignment batches.
Related Issue(s)
Fixes #
View Polygraph session ↗