Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AlessioDelConte opened this issue Feb 8, 2024 · 1 comment

Comments

@AlessioDelConte
Copy link

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

@kwonoj
Copy link
Member

kwonoj commented Feb 10, 2024

Dupe of #3015

@kwonoj kwonoj closed this as completed Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants