Skip to content

Commit 95a8564

Browse files
committed
fix: handle error when file is deleted while watcher is triggering
resolves #461
1 parent 694b740 commit 95a8564

File tree

1 file changed

+10
-5
lines changed
  • packages/vite-plugin-checker/src

1 file changed

+10
-5
lines changed

packages/vite-plugin-checker/src/glob.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ export function createIgnore(_root: string, pattern: string | string[] = []) {
2626
return true
2727
}
2828
const relativePath = relative(root, path).replace(/\\/g, '/')
29-
return (
30-
!!relativePath &&
31-
!matcher(relativePath) &&
32-
!(_stats ?? statSync(path)).isDirectory()
33-
)
29+
try {
30+
return (
31+
!!relativePath &&
32+
!matcher(relativePath) &&
33+
!(_stats ?? statSync(path)).isDirectory()
34+
)
35+
} catch {
36+
// do not ignore files that have been deleted as the watcher is iterating on them
37+
return false
38+
}
3439
}
3540
}

0 commit comments

Comments
 (0)