Commit 0a288d3
committed
watch: fix --watch-path restart on unrelated file with --env-file
When both --watch-path=<dir> and --env-file=<path> are provided,
touching any file in the directory containing the env file incorrectly
triggered a restart, even if the changed file was unrelated to the
watched path.
Root cause: filterFile() watches dirname(file) recursively on macOS
and Windows (platforms with recursive fs.watch support). In 'filter'
mode this is harmless because #onChange only fires for files in
#filteredFiles. But in 'all' mode (used when --watch-path is set),
#onChange fires for any change in any watched path without checking
the filter, so watching the env file's parent directory caused restarts
on every file change in that directory.
Fix: only watch the parent directory in 'filter' mode. In 'all' mode,
watch the specific file directly (watchPath(file, false)) so that
changes to unrelated files in the same directory are not observed.
Fixes: #619061 parent 9145cc6 commit 0a288d3
File tree
2 files changed
+47
-3
lines changed- lib/internal/watch_mode
- test/parallel
2 files changed
+47
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
133 | 135 | | |
134 | | - | |
135 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
164 | 205 | | |
165 | 206 | | |
166 | 207 | | |
| |||
0 commit comments