nodejs / nodejs/node

`fs.watch`: endless file events reported

未关闭
#61,398 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
JavaScript
星标
122k
派生
37.3k
平均合并
4 天 2 小时
30 天内合并 PR
283

描述

Version

v22.21.1

Platform
Microsoft Windows NT 10.0.26200.0 x64
Subsystem

No response

What steps will reproduce the bug?
  • create a folder vscode
  • run this command in that folder mkdir .vscode && echo {"editor.fontSize": 33}>.vscode\settings.json
  • run the following node.js script in a terminal pointing to the folder vscode/.vscode
  • run this command in that folder rmdir /s /q .vscode\ && mkdir .vscode && echo {"editor.fontSize": 33}>.vscode\settings.json
const fs = require("fs");

fs.watch("<path to a folder>/.vscode", (eventType, filename) => {
    if (filename) {
        console.log(`Event Type: ${eventType}`);
        console.log(`Filename: ${filename}`);
    } else {
        console.log("Filename not provided");
    }
});
How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior? Why is that the expected behavior?

After running the last command there should be change events reported in an endless fashion.

What do you see instead?

Endless reports of:

Filename: \\?\C:\Users\bpasero\Desktop\testing-watcher\.vscode
Event Type: rename
Filename: \\?\C:\Users\bpasero\Desktop\testing-watcher\.vscode
Event Type: rename
Filename: \\?\C:\Users\bpasero\Desktop\testing-watcher\.vscode
Event Type: rename
Filename: \\?\C:\Users\bpasero\Desktop\testing-watcher\.vscode
Event Type: rename
Additional information

Originally reported in VS Code repo as https://github.com/microsoft/vscode/issues/287800

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 fs.watch API 开始,使用提供的 Node.js 脚本重现 Windows 序列。将重复的重命名事件和路径值与所述的预期行为进行比较,然后跟踪 Windows 文件监视路径。当重现不再产生非预期的无休止事件,且相关行为已由测试覆盖时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js
领域
backend, operating-systems
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。