fix(filesystem): normalize watcher paths to forward slashes on Windows#35715
Open
C0d3N1nja97342 wants to merge 1 commit into
Open
fix(filesystem): normalize watcher paths to forward slashes on Windows#35715C0d3N1nja97342 wants to merge 1 commit into
C0d3N1nja97342 wants to merge 1 commit into
Conversation
@parcel/watcher emits paths with OS-native separators, so on Windows the callback receives backslash paths (e.g. `C:\foo\bar.txt`). The watcher published these verbatim, but the rest of the codebase compares and stores paths with forward slashes — causing path mismatches and inconsistent behavior (file operations, @file mentions, cache keys) on Windows. Normalize `update.path` to forward slashes before publishing (mirroring the `storagePath` normalization in database/path.ts). The option is a no-op on non-Windows platforms. Test changes: - Add a regression test asserting emitted paths contain no backslashes. - Wrap expected paths in the existing live tests with a `toPosix` helper so they compare correctly now that emitted paths are forward slashes (previously both sides used backslashes on Windows, so the comparison passed by coincidence without actually exercising normalization). Closes anomalyco#35329
C0d3N1nja97342
force-pushed
the
fix/watcher-backslash-paths-dev
branch
from
July 9, 2026 06:53
a006a73 to
8c8e03e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #35329
Type of change
What does this PR do?
@parcel/watcheremits paths with OS-native separators, so on Windows the subscribe callback receives backslash paths (e.g.C:\foo\bar.txt). The watcher published these verbatim toEvent.Updated, but the rest of the codebase compares and stores paths with forward slashes — so on Windows, watcher event paths never matched anything that expected forward slashes (file operations,@filementions, cache keys, etc.).The fix normalizes
update.pathto forward slashes before publishing, via a smallnormalizeWatchPathhelper that mirrors the existingstoragePathnormalization indatabase/path.ts. It's a no-op on non-Windows.How did you verify your code works?
@parcel/watcherscript: the raw callback path isC:\Users\...\sub(backslashes confirmed).replaceAll("\\", "/")normalization in that script and confirmed the emitted path becomesC:/Users/.../sub(no backslashes), including for nested subdirectories.tsc --noEmitonpackages/coreis clean (0 errors) with these changes.toPosixhelper so they still compare correctly now that emitted paths are forward slashes (previously both sides used backslashes on Windows, so the comparison passed without actually exercising normalization).Checklist