Sitelet https://github.com/nodejs/node/issues/42091
Skip to content

Add hasRef to worker_threads.Worker #42091

Description

@SimenB

What is the problem this feature will solve?

Jest has a --detect-open-handles flag which attempts to figure out (using async_hooks) what resources (timer/server etc.) are preventing a test run/node from exiting. To avoid false positives we perform filtering before presenting the list to the user. One of those things is to check if a Timer has been unrefed or not, via Timer.hasRef.

However, Workers have no hasRef, even though they have the {un}ref pair, so Jest will currently print false positives for Workers that have had unref called.

What is the feature you are proposing to solve the problem?

Add Worker.hasRef similar to the Timer API.

What alternatives have you considered?

No response

Activity

  1. targos commented on Feb 23, 2022

    @targos
    Member

    What about other APIs that have an unref function? ChildProcess, FSWatcher, etc.

  2. SimenB commented on Feb 23, 2022

    @SimenB
    MemberAuthor

    I haven't gotten a bug report in Jest about them, so I have no opinion 😀

    On a more serious note, I think it makes sense for ref, unref and hasRef to always exist together.

  3. added
    workerIssues and PRs related to the worker_threads module and Worker API.
    on Feb 23, 2022
  4. moved this to Pending Triage in Node.js feature requestson Feb 23, 2022
  5. benjamingr commented on Feb 23, 2022

    @benjamingr
    Member

    @SimenB would you be interested in contributing a PR? I am happy to guide you, the code is in io.js and worker.js mostly :)

  6. SimenB commented on Feb 23, 2022

    @SimenB
    MemberAuthor

    Io.js, that's a blast from the past! Happy to contribute it if it'll get accepted 🙂

  7. RaisinTen commented on Apr 16, 2022

    @RaisinTen
    Member

    Sent a PR for this: #42756

  8. 15 remaining items

  9. added a commit that references this issue on May 2, 2022
  10. SimenB commented on May 3, 2022

    @SimenB
    MemberAuthor

    @RaisinTen can confirm the jest detection works correctly on 18.1.0, thank you!

  11. moved this from Pending Triage to Done in Node.js feature requestson Jun 2, 2022
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

    feature requestIssues requesting new Node.js features.workerIssues and PRs related to the worker_threads module and Worker API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions