Skip to content

Watcher drops the full scan a directory removal or scope change asks for when the sync fails or the event arrives mid-sync #1964

Description

@inth3shadows

Some watcher events only request a full scan-diff: a removed directory (#1285) and a .gitignore / codegraph.json scope change (#1590) set needsFullScan without adding anything to pendingFiles. The gate that retries a failed sync, or runs the follow-up for events that landed mid-sync, checks only pendingFiles (src/sync/watcher.ts:990 on main ba3c21e):

if (this.pendingFiles.size > 0 && !this.stopped) {

So the full scan such an event asked for is dropped in two cases:

  1. The sync fails (lock contention or an error). It's never retried.
  2. The event arrives during a scoped sync. No follow-up full scan runs when that sync finishes.

In both cases the removed directory's symbols, or the files the new scope excludes, stay in the index until some unrelated edit triggers another sync.

Repro (the real FileWatcher with inertForTests, driven by ingestEventForTests; syncFn fails on its first call and records every call):

removed dir, lock failure         ["FULL"]                      ← never retried
removed dir, sync error           ["FULL"]                      ← never retried
control: src edit, lock failure   [["src/a.ts"],["src/a.ts"]]   ← retried

A directory removal that arrives during a scoped sync of src/a.ts gives [["src/a.ts"]], with no follow-up full scan.

Fix: reschedule when this.pendingFiles.size > 0 || this.needsFullScan.

#1875 already makes this exact change, for the case where an HDL filelist changes mid-sync. It fixes both cases above, but it's part of the Verilog feature. Filing this separately so the bug is tracked whether or not that PR lands as one piece. If it helps land sooner, I can open a small PR with just the gate change and regression tests for both cases.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions