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

node compat: chokidar not work on windows #23984

Closed
jeiea opened this issue May 25, 2024 · 0 comments · Fixed by #24434
Closed

node compat: chokidar not work on windows #23984

jeiea opened this issue May 25, 2024 · 0 comments · Fixed by #24434
Assignees
Labels
bug Something isn't working correctly node compat

Comments

@jeiea
Copy link
Contributor

jeiea commented May 25, 2024

Version: Deno 1.43.6

Steps to Reproduce

  1. On Windows, place some files in the sync/ directory.
  2. Run the following code:
import { watch } from "npm:chokidar";

main();

async function main() {
  const watcher = watch("sync/", {
    atomic: true,
    ignoreInitial: true,
  });

  watcher
    .on("add", (path, stats) => console.info(`File ${path} has been added`))
    .on("change", (path, stats) => console.info(`File ${path} has been changed`))
    .on("unlink", (path) => console.info(`File ${path} has been removed`))
    .on("error", (error) => {
      console.error("Error:", error);
    });

  await new Promise((resolve) => watcher.on("ready", resolve));
  console.info(`Watching: ${JSON.stringify(watcher.getWatched())}`);
}
  1. Create some file in sync directory.

Expected Behavior

It should print watching: <at least 3 items>, and detect file changes.

Actual Behavior

watching: {"D:\\":["sync"],"D:\\sync":[]}

It doesn't detect file changes.

Additional Context

I suspect the cause is the node:fs stat polyfill returning mode: null on windows. This seems like a regression because it broke my script, but from the history, It looks like this issue has been around for a while. I'm very curious about this issue.

import { lstat } from "node:fs/promises";

main();

async function main() {
  console.log(await lstat("000.txt", { bigint: true }));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants