Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.watch() strips backslash directory separators for filenames/paths on Windows #940

Open
WolfBearGames opened this issue Feb 23, 2024 · 1 comment
Assignees
Labels
api An issue, task, or discussion related to public runtime APIs bug Something isn't working javascript An issue, discussion, or task related to the runtime javascript runtime An issue, task, or discussion related to the runtime core windows

Comments

@WolfBearGames
Copy link

What OS are you using (uname -a, or Windows version)?

Windows 11

What version Socket Runtime are you using?

0.5.4 (f90ba12)

What did you expect to see and what you saw instead?

I'm using fs.watch() to watch a directory and its sub directories for changes. I expect to receive events for changes with the respected path in the event:

{ eventType: 'rename', filename: 'PuzzleNotes\SubTestPuzzle\Textdokument (neu).txt' }

instead, I get this:

{ eventType: 'rename', filename: 'PuzzleNotesSubTestPuzzleTextdokument (neu).txt' }

The directory separators are missing. I did not test on any other platform then Windows, but I could imagine the the \ (backslashes) are being stripped somethere in the ipc communication.

@jwerle jwerle self-assigned this Feb 27, 2024
@jwerle jwerle added bug Something isn't working windows javascript An issue, discussion, or task related to the runtime javascript api An issue, task, or discussion related to public runtime APIs runtime An issue, task, or discussion related to the runtime core labels Feb 27, 2024
@WolfBearGames
Copy link
Author

This could be another issue, but there are more problems with fs watch on Windows:

  1. renaming a file sometimes causes a "SyntaxError: Bad control character in string literal in JSON" (probably also because of backslash problems)
  2. deleting a file in Windows Explorer sometimes does not trigger any change event.
  3. the returned path for changes in subfolders sometimes is incomplete.

As a suggestion:
Is it possible to handle all the slash/backslash path "mess" in the socket API so that paths ALWAYS use forward slashes, even on Windows (and all Socket fs/path methods return paths with forward slashes)?
I tried converting the windows path to a "normal" path with slashes, but some methods like "path.join" re-introduce backslashes into the resulting path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api An issue, task, or discussion related to public runtime APIs bug Something isn't working javascript An issue, discussion, or task related to the runtime javascript runtime An issue, task, or discussion related to the runtime core windows
Projects
None yet
Development

No branches or pull requests

2 participants