Skip to content

Timer objects no longer show up in process._getActiveHandles() #25806

Description

@isaacs

Up until node v10, process._getActiveHandles() would show Timer objects that were keeping the process open.

For example:

$ node -v
v10.15.1

$ node -p 'setTimeout(_=>_,500);process._getActiveHandles().filter(h=>h!=process.stdout && h !=process.stderr)'
[ Timer {
    _list:
     TimersList {
       _idleNext: [Timeout],
       _idlePrev: [Timeout],
       _unrefed: false,
       msecs: 500,
       _timer: [Circular] } } ]

However, in Node v11, this is not the case:

$ node -v
v11.8.0

$ node -p 'setTimeout(_=>_,500);process._getActiveHandles().filter(h=>h!=process.stdout && h !=process.stderr)'
[]

Is there a better or more canonical way to get insight into what's keeping the process from exiting gracefully? Or is this a bug?

Activity

  1. richardlau commented on Jan 30, 2019

    @richardlau
    Member

    I think this is due to #20894 (#20894 (review)).

    cc @nodejs/timers @nodejs/diagnostics

  2. Fishrock123 commented on Jan 30, 2019

    @Fishrock123
    Contributor

    Yes, it is due to the aforementioned and related commits.

    The tl;dr has apparently been that no one really cares about _getActiveHandles(). This also broke some stuff internally at NodeSource at the time.


    EDIT: to be clear, this is because all of the timer's work aside from the single base timer handle is now all done in javascript, and also detached form the handle for efficiency with V8.

    See #21453 for a potential public version of this api, although really I think timers should maybe be a separate api, and continuations (nextTick, MTQ, setImmediate) an additional api still.

  3. added
    timersIssues and PRs related to timers, setImmediate(), setInterval(), and setTimeout().
    on Jan 30, 2019
  4. isaacs commented on Jan 30, 2019

    @isaacs
    ContributorAuthor

    @Fishrock123 Thanks for the link.

    The tl;dr has apparently been that no one really cares about _getActiveHandles().

    I care :(

    But yeah, it's always been a jank API. I'd be thrilled to see something better in that space.

    What's the likelihood of getting Timers brought back in some fashion in _getActiveHandles()? This seems like a bug to me.

  5. Fishrock123 commented on Jan 31, 2019

    @Fishrock123
    Contributor

    The tl;dr has apparently been that no one really cares about _getActiveHandles().

    I care :(

    I mean I'd like to say that I do too but it's been like 9 months. And, well, I want to get time to look at this again from a public api soon but, I say that a lot.

    I think it is unlikely that anyone will want to change/fix/whatever _getActiveHandles(). I don't 100% remember the context around the discussions at the time, though.

  6. vmarchaud commented on Feb 2, 2019

    @vmarchaud
    Contributor

    I believe those APIs are mainly used by APMs vendor, we got the issue too at @keymetrics (keymetrics/pm2-io-apm#213) and found a somewhat fix

  7. mmarchini commented on Feb 22, 2019

    @mmarchini
    Contributor

    To add to this discussion, llnode has it's own getactivehandles/getactiverequest commands, and while upgrading llnode to work with Node.js v11 some tests stopped working because of this change.

  8. apapirovski commented on Feb 24, 2023

    @apapirovski
    Contributor

    Given it has been 3+ years, at this point it seems like we should close and move on. Re-introducing is unlikely to add any value.

  9. kingshukbasak commented on Sep 9, 2024

    @kingshukbasak

    Hi, Having this feature can add a lot of value when there is a memory leak in an enterprise system due to increase in Active Handlers/Request. Hope the method is back.

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

    timersIssues and PRs related to timers, setImmediate(), setInterval(), and setTimeout().wontfixIssues that will not be fixed.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions