Skip to content

fs.watch() listener called with null filename argument #61520

Description

@lpinca

Version

main (commit 159ae48)

Platform

SunOS smartos 5.11 joyent_20260122T000642Z i86pc i386 i86pc

Subsystem

fs

What steps will reproduce the bug?

const fs = require('fs');

const watcher = fs.watch('.', {
  recursive: false // The test passes if this option is set to `true`.
});

watcher.on('change', function (event, filename) {
  console.log(event, filename);

  if (filename === 'file.txt') {
    watcher.close();
  }
});

setTimeout(function () {
  fs.writeFileSync('file.txt', 'data');
}, 100);

How often does it reproduce? Is there a required condition?

Always.

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

change file.txt is written to the standard output and the process exits. This is what happens when the recursive option is set to true.

What do you see instead?

change null is written to the standard output and the process does not exit.

Additional information

No response

Activity

  1. added
    smartosIssues and PRs related to the SmartOS platform.
    on Jan 25, 2026
  2. changed the title [-]`fs.watch()` listener called with null filename[/-] [+]`fs.watch()` listener called with `null` `filename` argument[/+] on Jan 25, 2026
  3. added
    fsIssues and PRs related to file-system APIs and the fs module.
    on Jan 25, 2026
  4. juanarbol commented on Jan 25, 2026

    @juanarbol
    Member

    Luigi, I know SunOS and FreeBSD are cousins. But I'm not fully sure if they share the same kernel bug. At least FreeBSD has the exact same issue, and it is due to the kernel.

    Refs: libuv/libuv#4606 (comment)

  5. lpinca commented on Jan 25, 2026

    @lpinca
    MemberAuthor

    I think the same test passes on FreeBSD? I've opened this as tracking issue for #61494 (comment) and I see no failure on FreeBSD.

  6. juanarbol commented on Jan 25, 2026

    @juanarbol
    Member

    I think the same test passes on FreeBSD? I've opened this as tracking issue for #61494 (comment) and I see no failure on FreeBSD.

    Don't trust me that much, but is that job actually doing something? https://ci.nodejs.org/job/node-test-commit-freebsd/63310/ I mean, ~5secs... and nothing under "Tests" section".

    @lpinca See nodejs/build@0cb941b and #54576, FreeBSD is pretty much disabled.

  7. added
    freebsdIssues and PRs related to the FreeBSD platform.
    on Jan 26, 2026
  8. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  9. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jul 20, 2026
  10. github-actions commented on Aug 20, 2026

    @github-actions
    Contributor

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    freebsdIssues and PRs related to the FreeBSD platform.fsIssues and PRs related to file-system APIs and the fs module.smartosIssues and PRs related to the SmartOS platform.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions