Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

vfs: RealFSProvider.watchFile ignores the listener and unwatchFile leaks it

Aberta
#66,223 0 comentários 0 reações 1 responsável Ver no GitHub

@trivikr já está trabalhando nisso.

Desde 23/9/2026.

Avaliação

Esta issue ainda não foi avaliada.

Descrição

vfs
Version

main

Platform
All
Subsystem

vfs

What steps will reproduce the bug?
import { mkdtempSync, watchFile, writeFileSync, unwatchFile } from "fs";
import { create, RealFSProvider } from "node:vfs";

const d = mkdtempSync("/tmp/v-");
const f = create(new RealFSProvider(d)).mount() + "/f";
const cb = () => console.log("fired");

watchFile(f, { interval:50 }, cb);

setTimeout(() => writeFileSync(f, "x"), 50);
setTimeout(() => {
  unwatchFile(f, cb);
  console.log("done, should exit");
}, 200);
How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?
fired
fired
done, should exit

fired prints within ~50–100ms of the write (the { interval: 50 } poll detects the stat change), then unwatchFile(f, cb) at 200ms removes the callback and the process exits cleanly with code 0.

What do you see instead?
done, should exit
<process hangs>

fired never prints - even though the change happens at 50ms and the watcher polls every 50ms for 150ms before unwatch. cb was never registered at all. The hang after done, should exit is the leaked stub keeping the loop alive.

Additional information

No response

Linguagem predominante
JavaScript
Estrelas
122k
Forks
37.4k
Merge médio
4d 2h
PRs com merge (30d)
277

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de nodejs/node

Todas as issues de nodejs/node

Issues semelhantes

Mais issues de JavaScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.