Skip to content

Commit 5183e3a

Browse files
lpincarichardlau
authored andcommitted
watch: clarify that the fileName parameter can be null
Add a comment to clarify that the `fileName` parameter can be `null` if the file name cannot be determined. PR-URL: #51305 Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 3badc11 commit 5183e3a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/internal/watch_mode/files_watcher.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,11 @@ class FilesWatcher extends EventEmitter {
9797
return;
9898
}
9999
const watcher = watch(path, { recursive, signal: this.#signal });
100-
watcher.on('change', (eventType, fileName) => this
101-
.#onChange(recursive ? resolve(path, fileName ?? '') : path));
100+
watcher.on('change', (eventType, fileName) => {
101+
// `fileName` can be `null` if it cannot be determined. See
102+
// https://github.com/nodejs/node/pull/49891#issuecomment-1744673430.
103+
this.#onChange(recursive ? resolve(path, fileName ?? '') : path);
104+
});
102105
this.#watchers.set(path, { handle: watcher, recursive });
103106
if (recursive) {
104107
this.#removeWatchedChildren(path);

0 commit comments

Comments
 (0)