ReactiveX/rxjs

Delay, timer and possibly other operators have a maximum milliseconds value, even when date is passsed

AlessioDelConte opened this issue · 1 comments

Describe the bug

I was trying to use a delay in a pipe that was supposed to trigger on the expiration of a JWT. The token had an expiration of 30 days from the moment it was released.
If the expiration is longer than 24.9 days (2147483648 ms), the those operators will not wait the proper amount of time.
I think this is due the fact that internally they are all using the setInterval function (?) that apparently has a cap to a 32 bit integer, corresponding to 2147483648 ms, namely 24.9 days.

This is also broken when passing a Date, which I think is converted back to milliseconds at some point.

I am fine with this limitations, but in the documentation there is no mention to this, and moreover there are examples where the delay is much longer than 25 days (like here there is an example with a date set to the year 2050).

Also, with using as possible input a date, it does not encourage at all these types of checks from the developer side, leading to very edge-cases bugs that can be quite tricky to track.

Expected behavior

When I create a timer or use a delay operator with a date set to 2050 I expect that the pipe will not trigger (or continue) until that specified date (or amount of time in case of milliseconds are passed).

Reproduction code

// Set the date as 30 days from today
timer(new Date('March 12, 2024 12:00:00')).subscribe(() => console.log("Time flies!"))

Reproduction URL

https://stackblitz.com/edit/rxjs-mrjeaj?file=index.ts

Version

7.8.0

Environment

No response

Additional context

No response

Dupe of #3015