Skip to content

Commit 3f7b6f1

Browse files
committed
Fix Windows path mismatch and clean up map on unlink
Two review-comment fixes from #7491: - shouldIgnoreEvent looked up event.path raw, but extensionWatchedFiles is keyed by normalizePath(file). On Windows, chokidar emits backslash-separated paths and the lookup would miss, causing runtime-discovered files to be re-filtered by the static-list check. Normalize before the lookup. - Runtime discovery added entries to extensionWatchedFiles but never removed them on unlink. In a long-running dev session the map grew unbounded with stale ownership data. Delete the normalized path from the map after pushing file_deleted; subsequent timeouts for other handles are no-ops on the now-missing key.
1 parent 2ef08a3 commit 3f7b6f1

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

packages/app/src/cli/services/dev/app-events/file-watcher.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,12 @@ export class FileWatcher {
226226

227227
// If this path is already tracked for this handle (either pre-registered or
228228
// discovered at runtime), accept without re-checking against the static list.
229-
if (event.extensionHandle && this.extensionWatchedFiles.get(event.path)?.has(event.extensionHandle)) {
229+
// The map is keyed by normalized paths, so normalize before the lookup —
230+
// chokidar can emit backslash-separated paths on Windows.
231+
if (
232+
event.extensionHandle &&
233+
this.extensionWatchedFiles.get(normalizePath(event.path))?.has(event.extensionHandle)
234+
) {
230235
return false
231236
}
232237

@@ -387,6 +392,10 @@ export class FileWatcher {
387392
// If the extensionPath is not longer in the list, the extension was deleted while the timeout was running.
388393
if (!this.extensionPaths.includes(extensionPath)) return
389394
this.pushEvent({type: 'file_deleted', path, extensionPath, extensionHandle, startTime})
395+
// Drop the path from our ownership map so it doesn't leak across a
396+
// long-running dev session. Subsequent timeouts for other handles
397+
// are no-ops on the now-missing key.
398+
this.extensionWatchedFiles.delete(normalizePath(path))
390399
// Force an emit because we are inside a timeout callback
391400
this.debouncedEmit()
392401
}, FILE_DELETE_TIMEOUT_IN_MS)

0 commit comments

Comments
 (0)