vfs: RealFSProvider.watchFile ignores the listener and unwatchFile leaks it
@trivikr já está trabalhando nisso.
Desde 23/9/2026.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
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
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de nodejs/node
-
doc
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
-
build
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
-
feature request
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Todas as issues de nodejs/node
Issues semelhantes
-
Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Automattic/safe-publish#594 ·
-
内部文件键(绝对路径的 base64)泄漏到界面标签 Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
NousResearch/hermes-agent#121143 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100