Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

The maximum time setTimeout can handle should be documented, and perhaps it should throw an exception when it's exceeded #3605

@calmh

Description

@calmh

It seems that setTimeout internally uses a signed 32 bit integer to represent the number of milliseconds to "sleep", giving a maximum delay of 2147483647 ms, about 24.9 days. This might seem like a lot, and I'm sure it doesn't pop up as an issue in in-browser Javascript implementations. However, there are a few cron modules in npm that naively use setTimeout and thus break on once-a-month and similar schedules.

The bug is in the module in question, for sure, but it would be nice if the documentation in http://nodejs.org/docs/latest/api/timers.html#setTimeout mentioned the constraints.

As far as I can see, the setTimeout method is only specified in some HTML5 draft (?) and it says nothing there about a maximum delay value or what should be done if it's exceeded. I'd consider it less surprising and more robust to have setTimeout throw an exception than call the callback immediately when the requested delay is impossible...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions