镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Change in return value of setTimeout #35770

Closed

Description

@kefasb
  • 12.19.0:
  • all:

What steps will reproduce the bug?

In node:12.19.0-slim docker image setTimeout function returns a value for which isNaN=false
In node:12.18.4-slim docker image setTimeout function returns a value for which isNaN=true

timeoutId = setTimeout(function() {alert("Timeout")}, 1000);
console.log(isNaN(timeoutId))

image

Is this an intentional behaviour?

Activity

  1. added
    timersIssues and PRs related to timers, setImmediate(), setInterval(), and setTimeout().
    on Oct 23, 2020
  2. Trott commented on Oct 23, 2020

    @Trott
    Member

    Is this an intentional behaviour?

    It was indeed an intentional change. #34017

    I wonder if perhaps that would have ideally been treated as semver-major, but I can see why that wasn't obvious at the time.

    @lundibundi @nodejs/timers

  3. Fishrock123 commented on Oct 25, 2020

    @Fishrock123
    Contributor

    I don't have much to add - the change is definitely something that should have happened at some point. The current maintainers will need figure out what, if anything, to do about this situation.

  4. kefasb commented on Oct 26, 2020

    @kefasb
    Author

    Thank you for clarification.

  5. benjamingr commented on Oct 26, 2020

    @benjamingr
    Member

    @kefasb just to point out - this change should have probably been communicated better and semver-major if people "in the wild" are running into cases where code that checks for node vs. browser timers is starting to fail.

    The idea was to make node timers easier to work with and this sort of usage pattern (someone using isNaN to check if the timer they got was a web browser) was missed on our part.

    Sorry for breaking your code!

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().

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions