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

setTimeout with high timeouts are fired immediately #3615

Closed
nicokaiser opened this issue Jul 2, 2012 · 1 comment
Closed

setTimeout with high timeouts are fired immediately #3615

nicokaiser opened this issue Jul 2, 2012 · 1 comment
Labels

Comments

@nicokaiser
Copy link

This console.log does not fire (at least for some years):

setTimeout(function() { console.log('PEW PEW'); }, 835371139071);

while this one fires immediately:

setTimeout(function() { console.log('PEW PEW'); }, 835371139072);

This behavior has changed since node 0.7.x, in 0.6 the second console.log also never fires (intended behavior).

What value is 835371139072 ? (This is the same for x64 and ia32).

@bnoordhuis
Copy link
Member

in 0.6 the second console.log also never fires (intended behavior).

Actually, it's the other way around. Both timeouts should fire immediately (that is, after the shortest possible interval) because that's what browsers do for timeouts > 2^31-1 and we follow browser behavior.

The fact that a timeout of 835371139071 doesn't actually work like that is due to an unfortunate bug: ~~835371139071 == 2147483647 which is exactly 2^31-1. See #3607 for details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants