File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed
crates/rspack_fs/src/watcher Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -88,9 +88,16 @@ impl DiskWatcher {
88
88
for pattern in already_watched_paths. difference ( & current_should_watch_paths) {
89
89
// If the path is no longer in the patterns to watch, unwatch it
90
90
if let Some ( watcher) = & mut self . inner {
91
- watcher
92
- . unwatch ( pattern)
93
- . map_err ( |e| rspack_error:: error!( e) ) ?;
91
+ // FIXME:
92
+ // we will unwatch the path is unnecessary, but we don't have a way to check if the path is still in the patterns
93
+ // notify will remove the watch path when path is removed in it's inner.
94
+ // If we unwatch the path again, it will return a error.
95
+ // So we just ignore the error here.
96
+ if let Err ( e) = watcher. unwatch ( pattern) {
97
+ if !matches ! ( e. kind, notify:: ErrorKind :: WatchNotFound ) {
98
+ return Err ( rspack_error:: error!( e) ) ;
99
+ }
100
+ }
94
101
}
95
102
}
96
103
Original file line number Diff line number Diff line change @@ -105,14 +105,17 @@ export default class NativeWatchFileSystem implements WatchFileSystem {
105
105
[ Array . from ( directories . added ! ) , Array . from ( directories . removed ! ) ] ,
106
106
[ Array . from ( missing . added ! ) , Array . from ( missing . removed ! ) ] ,
107
107
( err : Error | null , result ) => {
108
- const { changedFiles, removedFiles } = result ;
109
-
110
- const fs = this . #inputFileSystem;
111
- for ( const item of changedFiles ) {
112
- fs . purge ?.( item ) ;
113
- }
114
- for ( const item of removedFiles ) {
115
- fs . purge ?.( item ) ;
108
+ // !!if there is an error, result maybe a undefined value
109
+ const changedFiles = result ?. changedFiles || [ ] ;
110
+ const removedFiles = result ?. removedFiles || [ ] ;
111
+ if ( this . #inputFileSystem?. purge ) {
112
+ const fs = this . #inputFileSystem;
113
+ for ( const item of changedFiles ) {
114
+ fs . purge ?.( item ) ;
115
+ }
116
+ for ( const item of removedFiles ) {
117
+ fs . purge ?.( item ) ;
118
+ }
116
119
}
117
120
118
121
// TODO: add fileTimeInfoEntries and contextTimeInfoEntries
You can’t perform that action at this time.
0 commit comments