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

Timer operator does not work correctly on certain dates #5694

Closed
bretbas opened this issue Sep 4, 2020 · 4 comments
Closed

Timer operator does not work correctly on certain dates #5694

bretbas opened this issue Sep 4, 2020 · 4 comments

Comments

@bretbas
Copy link

bretbas commented Sep 4, 2020

Bug Report

Current Behavior
The timer operator is emit value immediately when we pass the current date(now) with adding from 75 to 99 days

Reproduction
https://stackblitz.com/edit/angular-ivy-uuf9za?file=src/app/app.component.ts

@kwonoj
Copy link
Member

kwonoj commented Sep 4, 2020

I believe this is dupe of #3015.

@bretbas
Copy link
Author

bretbas commented Sep 5, 2020

@kwonoj , But if this problem is due to overflow, then why does it work with dates adding days more than 99?

@kwonoj
Copy link
Member

kwonoj commented Sep 5, 2020

then why does it work with dates adding days more than 99?

it does not. If you only subscribe to date(100) for example,

const {timer} = require('rxjs');
const {mapTo} = require('rxjs/operators');

const addDays = (date, days) => {
  const d = new Date(date);
  d.setDate(d.getDate() + days);
  return d;
}

const now = new Date(Date.now());

const days = [
  timer(addDays(now, 74))
    .pipe(mapTo(74)),
  timer(addDays(now, 75))
    .pipe(mapTo(75)),
  timer(addDays(now, 99))
    .pipe(mapTo(99)),
  timer(addDays(now, 100))
    .pipe(mapTo(100))
]

days[3].subscribe((x) => console.log(x));

it emits warning

(node:13908) TimeoutOverflowWarning: 8643599998 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.
(Use `node --trace-warnings ...` to show where the warning was created)
100

and duration falls back to default but not sync, so it emits asynchronously. If it correctly works, opening up page should not write any output since date due is set to more than one month.

@kwonoj
Copy link
Member

kwonoj commented Sep 5, 2020

closing as dupe.

@kwonoj kwonoj closed this as completed Sep 5, 2020
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