Skip to content

fix(core): report removed snapshot worktree as snapshot error - #2

Open
perinst wants to merge 1 commit into
self-devfrom
snapshot-removed-worktree
Open

perinst wants to merge 1 commit into
self-devfrom
snapshot-removed-worktree

Conversation

@perinst

@perinst perinst commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Issue for this PR

Closes anomalyco#50548

Type of change

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

What does this PR do?

Snapshot resolves the source worktree with fs.realPath(source.worktree).pipe(Effect.orDie). If that directory is removed after Git discovery, the NotFound error becomes a defect. capture() only catches failures, so the defect escapes it and crashes the snapshot fiber instead of degrading.

This PR maps that error to Snapshot.Error with the same failure("capture", ...) helper the next line of the effect already uses:

  • capture() logs a warning and returns undefined, the same as its other failures, so snapshots are reported as unavailable.
  • files, diff, and restore return a typed Snapshot.Error instead of a defect.

This only covers the snapshot service. It does not fix the saved dead project path in the desktop client, which is tracked in anomalyco#50137.

How did you verify your code works?

  • bun test test/snapshot.test.ts in packages/core: 12 pass, 0 fail.
  • Added a regression test, "reports a worktree removed after discovery as a snapshot error". It fakes realPath to fail with NotFound. With the old orDie it fails because the defect escapes capture(). With this change it passes.
  • bun typecheck in packages/core: clean.
  • I did not run bun run check from the repo root.

Screenshots / recordings

N/A, not a UI change.

Checklist

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

Replace the Effect.orDie on realPath of the source worktree with a Snapshot.Error. capture() already logs and returns undefined on failure, so a worktree removed after discovery no longer escapes as a defect.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eb781933-a601-4650-bee3-5e0755a5fec4
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

fix(filesystem): crash when project directory does not exist

1 participant