Skip to content

fix(core): release per-run process listeners and task history results - #36866

Open
AgentEnder wants to merge 1 commit into
masterfrom
vf-leak-9df6a131
Open

fix(core): release per-run process listeners and task history results#36866
AgentEnder wants to merge 1 commit into
masterfrom
vf-leak-9df6a131

Conversation

@AgentEnder

Copy link
Copy Markdown
Member

Current Behavior

Every runDiscreteTasks call 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.pendingResults also keeps every TaskResult for 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 ↗

@netlify

netlify Bot commented Aug 31, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 33b55c8
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a98976013e2130008ccd49b
😎 Deploy Preview https://deploy-preview-36866--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.

@netlify

netlify Bot commented Aug 31, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 33b55c8
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a9897604e1e2a00089297db
😎 Deploy Preview https://deploy-preview-36866--nx-dev.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

nx-cloud Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 33b55c8

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ✅ Succeeded 57m 10s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 42s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 17s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-02 22:40:06 UTC

@AgentEnder
AgentEnder marked this pull request as ready for review August 31, 2026 20:20
@AgentEnder
AgentEnder requested a review from a team as a code owner August 31, 2026 20:20
@github-actions

Copy link
Copy Markdown
Contributor

🐳 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-workspace

Or just copy this version and use it in your own command:

23.2.0-pr.36866.449f6f3
Release details 📑
Published version 23.2.0-pr.36866.449f6f3
Triggered by @AgentEnder
Branch vf-leak-9df6a131
Commit 449f6f3
Workflow run 33435567767

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

@AgentEnder
AgentEnder force-pushed the vf-leak-9df6a131 branch 4 times, most recently from 3ce7fc7 to 12868de Compare September 1, 2026 22:28
nx-cloud[bot]

This comment was marked as outdated.

@nx-cloud nx-cloud Bot left a comment

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.

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.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants