GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): bound finished daemon shell commands across Locations by craigalbrecht · Pull Request #64037 · anomalyco/opencode

Conversation

@craigalbrecht

@craigalbrecht craigalbrecht commented Nov 15, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #63976

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The shell daemon previously evicted finished commands only per Location (25 per directory), while the global daemon sweep only removed entries older than 7 days or missing output files. In a long-lived opencode serve process running shell commands across multiple directories or worktrees, each directory retained up to 25 unreaped daemon children (<defunct>), growing unboundedly with the number of directories used.

This adds a daemon-wide LRU cap (DAEMON_EXITED_LIMIT = 100) in packages/core/src/shell.ts across all Locations in daemonLayer. When total retained finished commands exceed 100, the oldest finished entries are evicted and terminated (evictExited), while still keeping per-Location eviction at 25 and preserving recent command recovery.

How did you verify your code works?

Added a regression test in packages/core/test/shell-daemon.test.ts (bounds the finished commands one server keeps in the daemon across all its Locations) that runs commands across multiple Locations on a single daemon and verifies retained finished commands stay bounded at 100.

  • bun test test/shell-daemon.test.ts: 15 passed, 0 failed (88 expect() calls)
  • bun run typecheck: 0 errors (1,981 files across 2 projects)
  • Pre-push bun run lint && bun run typecheck: 35/35 passed

Screenshots / recordings

N/A — daemon process lifecycle fix.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #63817

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@craigalbrecht
fix(core): bound finished daemon shell commands across Locations
c79a480
@github-actions github-actions Bot added the contributor label Nov 15, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 15, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The fix works. I ran the issue's reproduction from source with 6 directories × 30 commands. On the base, the daemon's zombie children went 25 → 50 → … → 150. With this PR they stop at 100. The shell daemon tests pass and tsc is clean.

Public API: unchanged. The new DAEMON_EXITED_LIMIT export is internal to packages/core.

The shared map with delete-before-remove looks safe when several Locations trim at the same time, and per-Location eviction keeps the global map in sync through remove. One non-blocking gap is noted inline: the global cap only covers finished commands this server has taken back, so after a handoff, commands from Locations that are never reopened still sit outside it.

Related: #63817

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/shell.ts
)
finished
.toSorted((a, b) => (a.info.time.completed ?? 0) - (b.info.time.completed ?? 0))
.forEach((run) => retain(run.info.id))

@opencodejr opencodejr Bot Nov 15, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Non-blocking: finished commands left by a previous server are only added to exited when their Location is reopened (recover runs lazily from at). After a handoff, finished pipes from Locations that aren't reopened stay in the daemon outside the 100 cap until the 7-day sweep. A Location reopened later also puts its old commands at the newest end of the global order, so they can push out more recent commands from other Locations. If the goal is a daemon-wide bound across handoffs, you could count unclaimed exited pipes in pty.listPipes() once at startup, or have cleanup trim them. If not, it would help to note that the cap is per server lifetime.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jwitmann jwitmann mentioned this pull request Nov 16, 2026
opencode-pty daemon leaks zombie child processes (unbounded growth under single daemon PID) #63976
Closed
@nkoynov nkoynov mentioned this pull request Nov 16, 2026
shell: processes a finished command left in its group are SIGKILLed 25 commands later, not at exit #64177
Closed
@opencodejr opencodejr Bot mentioned this pull request Nov 16, 2026
pty: opencode-pty daemon leaks zombie shell children (never reaped) #64270
Closed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

opencode-pty daemon leaks zombie child processes (unbounded growth under single daemon PID)

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@craigalbrecht
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.