ReactiveX/rxjs

Having two `interval` streams running at the same time sometimes causes them to freeze/halt

matem1 opened this issue · 2 comments

matem1 commented

Describe the bug

I have two streams created with interval operator:

  • "main" which emits every 60 seconds
  • "secondary" which emits every 3 seconds

When they run at the same time, sometimes they "freeze" or "halt" and do not emit for some time. It happens randomly, I didn't find one rule by which it occurs.

Expected behavior

The streams created with interval operator should emit according to the time that was set at the beginning.

Reproduction code

No response

Reproduction URL

https://stackblitz.com/edit/stackblitz-starters-6jltsf?file=src%2Fmain.ts

Version

7.8.1

Environment

No response

Additional context

The code in Stackblitz measures time between each emission for two streams: main and secondary. Then compares this time to the one set in interval operator. If the time measured is 1.5x (or more) times greater than original one then report error to the console.
Below you can see two screenshots that I took. They show that it occurs randomly (sometimes there are no errors):

Here you can see that it took 127 emissions for secondary stream to exceed its original interval time (3 seconds) by around 16s and 35s seconds.
rxjs-interval-err

Here it happened quite quickly and for both main and secondary.
rxjs-interval-err4-early

matem1 commented

Yep, seems like it.