rxjs: RxJS asapScheduler stops working in 7.5.1
Describe the bug
While trying to upgrade from RxJS6 to RxJS7 I noticed that sometimes our observables were not being executed. After debugging I found that at least asapScheduler
did not always run the passed in callback function.
Expected behavior
asapScheduler
should always run
Reproduction code
See the stackblitz
See the instructions in the stackblitz:
// To reproduce the issue (rxjs @ 7.5.1):
// 1. load this in stackblitz
// 2. observe that the logs up to '))) n 4' are printed
// 3. make a change to this file, note that it does not work (nothing runs)
// 4. reload the stackblitz page, you will see it work again
// To have it always work (rxjs @ 6.6.7):
// 1. load this in stackblitz
// 2. in the "Dependencies" on the left, enter rxjs@6.6.7
// 2. observe that the logs up to '))) n 4' are printed
// 3. make a change to this file, note that it still works
In our own application, this stops working after ~135 calls to the asapScheduler
. The same two calls were failing, but I could cause it to fail sooner if I used asapScheduler
more frequently. I managed to get it to fail in stackblitz, but only while changing the stackblitz file. I’m not 100% sure this reproduces the issue in our own application, but the symptoms are the same, and in both 6.6.7 works
Reproduction URL
https://stackblitz.com/edit/rxjs-htf8tz?file=index.ts
Version
7.5.1
Environment
7.5.1 is causing the issue, but 6.6.7 works as expected
Additional context
Experienced in our corporate Angular 13 application
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 29 (10 by maintainers)
Okay… so here’s the thing… THE ORIGINAL ISSUE that was filed here is indeed fixed as of 7.5.7.
There’s a separate issue that is documented here: https://github.com/ReactiveX/rxjs/issues/6747#issuecomment-1360958245
I’m going to open a new Issue for that, and close this one to prevent confusion.
A friendly reminder to some of the snark in here: This is free software maintained by unpaid volunteers. I understand you’re frustrated, but I’m quite literally not paid to deal with you.
It’s this line:
https://github.com/ReactiveX/rxjs/blob/6d011f0dc67b736adc0979d3bc14d93b49064efa/src/internal/scheduler/AsapAction.ts#L35
_scheduled
cannot be set toundefined
unless it’s equal toid
. That’s what’s preventing further actions from being executed in this issue. However, looking at the source, I’m not sure that’s the only problem. I’m going to create a failing test for this situation and will then open a PR to fix it. And I’ll have more of a think about what I suspect are additional issues with the current implementation.CORE TEAM: Needs to be fixed in v7 and v8. We’ll likely be introducing new/better/smaller schedulers for v9.
We’ll discuss this in next core team meeting again to confirm.
Can this please be addressed? It is a blocking bug and it is not fixed in any rxjs version. It has been broken for a year now with no one attempting to resolve the issue thus far.
This should be fixed as of rxjs@7.5.7, please update.
Ane news about that? Ngrx component store debounce use it… With this bug the debounced selectors stop working from time to time which means it’s a blocker. We can’t upgrade above 7.4.x with this bug
Still doesn’t work for our project after updating to 7.5.7. This issue should not be closed.