Skip to content

Missing Node.js / timers definition #3480

@phillipj

Description

@phillipj

Hi,

I'm getting check errors when using .unref() on timers in Node.js. In practise I'm using .unref() to ensure the process can shutdown properly. Without it the process will not exit by itself cause the event loop isn't empty.

I'm more than happy to create a PR with the definition, but not sure what the best approach would be to avoid breaking the current definitions of clearInterval() and clearTimeout(). Making the Node.js setInterval() return a timer instance as described in the Node.js docs, would not work with the mentioned clear-methods expecting a number: https://github.com/facebook/flow/blob/master/lib/core.js#L766.

Any thoughts?

metrics.js

setInterval(reportProcessMetrics, 10 * 1000).unref();

output

metrics.js:58
 58:   setInterval(reportProcessMetrics, 10 * 1000).unref();
                                                    ^^^^^ property `unref`. Property not found in
 58:   setInterval(reportProcessMetrics, 10 * 1000).unref();
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Number

Refs Node.js Timers docs: https://nodejs.org/api/timers.html#timers_class_timeout

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions