Skip to content

fix(scanner): skip files that vanish mid-walk instead of failing (#302) - #303

Open
JordanCoin wants to merge 3 commits into
mainfrom
cursor/skip-vanished-walk-entries-38c3
Open

JordanCoin wants to merge 3 commits into
mainfrom
cursor/skip-vanished-walk-entries-38c3

Conversation

@JordanCoin

@JordanCoin JordanCoin commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

What does this PR do?

Fixes #302. When the tree walk lists a directory then lstats each entry, a short-lived file removed in between (e.g. watch.transition while the watcher runs) used to abort the whole walk with Error walking tree: lstat …: no such file or directory, which made SessionStart:resume fail intermittently on macOS.

ENOENT on a non-root walk entry is now skipped; a missing walk root still errors. The same skip is applied in the topology inventory walk (using os.Lstat so Windows does not keep FindFirstFile-cached metadata after a mid-walk delete). .codemap/ was already in IgnoredDirs (#196); the comment now notes that also avoids races on ephemeral state files there.

Type of change

  • Bug fix
  • New feature
  • New language support
  • Documentation
  • Other (describe below)

Checklist

  • I've tested this locally with go build && ./codemap .
  • I've read CONTRIBUTING.md (for new language support)
  • I've updated documentation if needed

Additional notes

  • TestScanFilesSkipsVanishedEntry deletes a later sibling mid-walk via a test hook and asserts the walk succeeds.
  • TestScanFilesMissingRootStillErrors pins that a missing root is still fatal.
  • TestDiscoverInventorySkipsVanishedEntries covers topology's file and directory ENOENT skips (also exercises Windows Lstat vs cached DirEntry.Info).
  • Without the skip, the scanner mid-walk test fails with the same lstat …: no such file or directory symptom as the issue.
Open in Web Open in Cursor 

SessionStart:resume could die with "Error walking tree: lstat …: no such
file or directory" when a short-lived entry (e.g. watch.transition) was
removed between ReadDir and Lstat. Treat that ENOENT as skip; keep a
missing walk root fatal. .codemap/ was already in IgnoredDirs; note why.

Co-authored-by: Jordan Coin Jackson <jordancoinjackson@gmail.com>
@codecov-commenter

codecov-commenter commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

cursoragent and others added 2 commits November 21, 2026 03:49
Codecov flagged the topology walk's IsNotExist branches; exercise both
entry.Info and directory ReadDir races the same way as the scanner test.

Co-authored-by: Jordan Coin Jackson <jordancoinjackson@gmail.com>
…es (#302)

DirEntry.Info can return FindFirstFile-cached metadata after a remove, so
TestDiscoverInventorySkipsVanishedEntries kept z-vanish.go on windows-latest.

Co-authored-by: Jordan Coin Jackson <jordancoinjackson@gmail.com>
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.

SessionStart hook fails with "Error walking tree: lstat .codemap/watch.transition: no such file or directory"

3 participants