Skip to content

fix(agent-core): stop retrying exhausted file watchers - #2933

Draft
mameikagou wants to merge 1 commit into
MoonshotAI:mainfrom
mameikagou:agent/disable-exhausted-fs-watchers
Draft

fix(agent-core): stop retrying exhausted file watchers#2933
mameikagou wants to merge 1 commit into
MoonshotAI:mainfrom
mameikagou:agent/disable-exhausted-fs-watchers

Conversation

@mameikagou

Copy link
Copy Markdown

Related Issue

Related to #2929

Problem

When a host filesystem watcher hits EMFILE or ENFILE, retrying cannot recover until descriptors are released. The native signal watcher currently treats these errors as transient, emits invalidations, and repeatedly rearms itself; the precise watcher also stays live after reporting the error. That can amplify resource exhaustion instead of letting the CLI continue with file watching disabled for the affected handle.

What changed

  • Treat EMFILE and ENFILE as terminal for the affected watch handle.
  • Close precise watchers and stop native retries while still reporting the original error once.
  • Resolve watch readiness so startup can continue in degraded mode.
  • Cover synchronous and asynchronous native failures for both resource-exhaustion codes.

Verification

  • pnpm --filter @moonshot-ai/agent-core-v2 lint:imports
  • pnpm --filter @moonshot-ai/agent-core-v2 typecheck
  • pnpm --filter @moonshot-ai/agent-core-v2 exec vitest run test/os/backends/node-local/hostFsWatchService.test.ts (15 passed, 1 platform skip)

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9922758

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant