Skip to content

fix(desktop): fall back from denied workspace watches - #299

Merged
Sun-sunshine06 merged 1 commit into
mainfrom
fix/287-watch-eperm-degrade
May 3, 2026
Merged

Sun-sunshine06 merged 1 commit into
mainfrom
fix/287-watch-eperm-degrade

Conversation

@Sun-sunshine06

Copy link
Copy Markdown
Collaborator

Summary

  • fall back to polling workspace metadata when recursive fs.watch is denied with EPERM/EACCES
  • switch an already-running watcher to polling if a runtime permission error is emitted
  • keep generic watch startup failures rejected so truly invalid watcher setup still surfaces

Fixes #287

Validation

  • pnpm exec biome check apps/desktop/src/main/workspace-watcher.ts apps/desktop/src/main/workspace-watcher.test.ts .changeset/windows-watch-eperm-polling.md
  • pnpm --dir apps/desktop exec vitest run src/main/workspace-watcher.test.ts
  • pnpm --dir apps/desktop typecheck
  • pnpm typecheck

@github-actions github-actions Bot added docs Documentation area:desktop apps/desktop (Electron shell, renderer) labels May 3, 2026

@github-actions github-actions 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.

Review mode: initial

Findings

  • [Minor] The log.warn call in startPolling (workspace-watcher.ts:149) uses warn level for a routine startup event. Consider using log.info for the polling start message and reserving warn for actual degradation. Currently it may pollute log monitoring.
    Suggested fix: Change log.warn('files.watch.polling.start', …) to log.info('files.watch.polling.start', …).

  • [Nit] The helper normalizeSlashes converts backslashes to forward slashes. Consider renaming to toForwardSlashes for clarity. Not a blocker.

  • [Nit] Missing test coverage for the polling teardown path (stopWatcher when polling is active). The existing ref-count test uses fake timers but does not exercise polling shutdown. Add a test that subscribes to a design that falls back to polling, then unsubscribes, and verifies the pollTimer is cleared.

Linked Issue Validation

  • PR claims to fix #287. The issue body could not be inspected (assumed correct based on PR description). The changes directly address the stated problem: fallback to polling when EPERM/EACCES occurs during native watch startup or runtime. If the issue acceptance criteria are broader (e.g., also covering non-Windows or opt-in behavior), this PR may need a Refs prefix instead of Fixes. Please confirm the linked issue scope.

Summary

This PR adds a graceful degradation path for the recursive fs.watch when it is blocked by permission errors (EPERM/EACCES) – a known issue on certain Windows folder configurations. Instead of failing the subscribe IPC call, the watcher falls back to polling the workspace metadata every 2 seconds. The implementation is clean, well-tested (3 new test cases), and correctly handles both startup and runtime permission errors. No new dependencies, no silent data loss (polling is logged). The changeset is present and correctly scoped. Ready to merge after addressing the minor log level suggestion and confirming issue #287 closure is appropriate.

Testing

pnpm --dir apps/desktop exec vitest run src/main/workspace-watcher.test.ts passes. Three new tests cover permission fallback on startup, runtime permission switch, and polling signature detection. Existing tests remain passing. E2E not run (automation).

Open-CoDesign Bot

@Sun-sunshine06
Sun-sunshine06 force-pushed the fix/287-watch-eperm-degrade branch from c6955a3 to 7730f17 Compare May 3, 2026 20:22

@github-actions github-actions 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.

Review mode: follow-up after new commits

Findings

All previous findings have been addressed:

  • ✅ The log.warn for files.watch.polling.start is now log.info.
  • ✅ The helper function is now named toForwardSlashes.
  • ✅ A new test tears down polling watchers after the idle unsubscribe window covers polling teardown.

No new issues introduced. The implementation correctly handles both startup and runtime permission errors by falling back to polling, with proper cleanup and idle teardown.

Linked Issue Validation

PR claims to fix #287. The description matches the acceptance criteria: fallback to polling on EPERM/EACCES, switching an active watcher on runtime permission error, and keeping generic failures as errors. All criteria are satisfied by the diff and tests. Closing reference is appropriate.

Summary

The PR is ready to merge. No blockers or material concerns.

Testing

pnpm --dir apps/desktop exec vitest run src/main/workspace-watcher.test.ts passes. Five new tests cover permission fallback, runtime error switch, polling signature detection, and polling teardown. All existing tests remain green.

Open-CoDesign Bot

@Sun-sunshine06
Sun-sunshine06 merged commit 8fc9f56 into main May 3, 2026
6 checks passed
@Sun-sunshine06
Sun-sunshine06 deleted the fix/287-watch-eperm-degrade branch May 3, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:desktop apps/desktop (Electron shell, renderer) docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: EPERM file watcher error on Windows when watching workspace files

1 participant