Skip to content

fix: mitigate transient spawn ENOENT during update windows#305

Open
liuxiaopai-ai wants to merge 3 commits intolukilabs:mainfrom
liuxiaopai-ai:fix/issue-268-spawn-enoent-retry
Open

fix: mitigate transient spawn ENOENT during update windows#305
liuxiaopai-ai wants to merge 3 commits intolukilabs:mainfrom
liuxiaopai-ai:fix/issue-268-spawn-enoent-retry

Conversation

@liuxiaopai-ai
Copy link
Copy Markdown

@liuxiaopai-ai liuxiaopai-ai commented Feb 27, 2026

Summary

Mitigate transient spawn ENOENT failures reported in #268 during update/restart windows.

This PR applies a two-layer fix:

  1. Recover from transient runtime unavailability with a one-time retry in ClaudeAgent
  2. Reduce race window by preventing update install while sessions are actively processing

Changes

  • packages/shared/src/agent/claude-agent.ts

    • Detect transient spawn + ENOENT in chat error flow
    • Emit user-facing info message: runtime temporarily unavailable, retrying
    • Retry once after 2 seconds (_isRetry guard prevents loops)
  • apps/electron/src/main/auto-update.ts

    • Add setHasActiveProcessingSessionsChecker() callback
    • In installUpdate(), block installation if any session is currently processing
    • Return clear error message for UI: wait for active task to finish first
  • apps/electron/src/main/index.ts

    • Wire SessionManager into auto-update checker via session.isProcessing

Why this approach

  • Keeps behavior conservative and low risk
  • Preserves existing non-transient error behavior
  • Addresses both symptom recovery and update-time contention

Validation

  • bun test packages/shared/src/agent/__tests__/base-agent.test.ts
  • bun x tsc -p apps/electron/tsconfig.json --noEmit

Fixes #268

liuxiaopai-ai and others added 2 commits February 27, 2026 11:16
Handle transient spawn ENOENT errors (e.g. during app bundle swap on auto-update) by retrying once after a short delay before surfacing the error.

Refs lukilabs#268

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
Prevent update install/restart while any session is actively processing to reduce bundle-swap race windows.

Refs lukilabs#268

Co-Authored-By: Craft Agent <agents-noreply@craft.do>
@liuxiaopai-ai liuxiaopai-ai changed the title fix: retry once on transient spawn ENOENT in ClaudeAgent fix: mitigate transient spawn ENOENT during update windows Feb 27, 2026
Handle unexpected checker failures gracefully so install flow doesn’t crash if session state probing throws.\n\nRefs lukilabs#268\n\nCo-Authored-By: Craft Agent <agents-noreply@craft.do>
@liuxiaopai-ai
Copy link
Copy Markdown
Author

Friendly ping for review when you have bandwidth 🙏\n\nThis PR addresses #268 with a conservative two-layer mitigation:\n- retry once on transient spawn ENOENT in ClaudeAgent\n- block update install while any session is actively processing\n\nFollow-up hardening included: session checker errors are handled defensively before install.\n\nValidation run locally:\n- bun run typecheck:all\n- bun run --cwd apps/electron typecheck\n- bun test packages/shared/src/agent/tests/\n- bun test apps/electron/src/main/tests/\n- targeted eslint on changed files\n\nHappy to adjust quickly based on maintainer feedback.

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.

Spawn ENOENT race condition during auto-update app bundle swap

1 participant