-
Notifications
You must be signed in to change notification settings - Fork 3k
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
RxJS asapScheduler stops working in 7.5.1 #6747
Comments
AFAICT, this was introduced in 7.5.0 in #6674. So 7.4.x should be okay. I think I can see |
It appears that it's not incrementing the |
It's this line: rxjs/src/internal/scheduler/AsapAction.ts Line 35 in 6d011f0
|
can confirm this problem. cost me an entire day to narrow it down the asap scheduler. (and in the end I really wanted to use the queue scheduler anyway lol) |
Confirmed. My tests that use asapScheduler broke after I upgraded to the latest Rxjs version. |
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 |
Same here. Can't upgrade to Angular 14 because @ngrx/component-store stops working correctly. |
There’s an apparent memory leak in the |
Any news on this? |
Hi @aldrashan ! I'm pretty sure that this issue got fixed on version |
Hey @aldrashan and @josepot.
I'm sorry, but the mentioned commit didn't fix this issue. The commit message mentioned that it was related to this issue, but it wasn't a fix. The change log generator generated an inaccurate message which Ben fixed with this commit - it most probably went unseen. Sorry about this. |
It appears that |
I think I am seeing the same issue, with Please see this StackBlitz: In this case, we are calling As @cartant pointed out, the issue seems to be in the line that clears The problem was introduced in NOTE - If you let StackBlitz auto-refresh the console when editing it will preserve the |
Update: calling See the updated StackBlitz: |
Any chance this got fixed yet? |
As a workaround I have created a custom scheduler based on #6889 import {SchedulerAction} from "rxjs"
import {immediateProvider} from "rxjs/internal/scheduler/immediateProvider"
import {AsapScheduler} from "rxjs/internal/scheduler/AsapScheduler"
import {AsyncAction} from "rxjs/internal/scheduler/AsyncAction"
// see https://github.com/ReactiveX/rxjs/pull/6889
// fix: animationFrameScheduler and asapScheduler no longer executing actions #6889
export class CustomAsapAction<T> extends AsyncAction<T> {
constructor(protected scheduler: AsapScheduler, protected work: (this: SchedulerAction<T>, state?: T) => void) {
super(scheduler, work);
}
protected requestAsyncId(scheduler: AsapScheduler, id?: any, delay: number = 0): any {
// If delay is greater than 0, request as an async action.
if (delay !== null && delay > 0) {
return super.requestAsyncId(scheduler, id, delay);
}
// Push the action to the end of the scheduler queue.
scheduler.actions.push(this);
// If a microtask has already been scheduled, don't schedule another
// one. If a microtask hasn't been scheduled yet, schedule one now. Return
// the current scheduled microtask id.
// @ts-ignore
return scheduler._scheduled || (scheduler._scheduled = immediateProvider.setImmediate(scheduler.flush.bind(scheduler, undefined)));
}
protected recycleAsyncId(scheduler: AsapScheduler, id?: any, delay: number = 0): any {
// If delay exists and is greater than 0, or if the delay is null (the
// action wasn't rescheduled) but was originally scheduled as an async
// action, then recycle as an async action.
if ((delay != null && delay > 0) || (delay == null && this.delay > 0)) {
return super.recycleAsyncId(scheduler, id, delay);
}
// If the scheduler queue has no remaining actions for the next schedule,
// cancel the requested microtask and set the scheduled flag to undefined
// so the next AsapAction will request its own.
// @ts-ignore
if (scheduler._scheduled === id && !scheduler.actions.some((action) => action.id === id)) {
immediateProvider.clearImmediate(id);
// @ts-ignore
scheduler._scheduled = undefined;
}
// Return undefined so the action knows to request a new async id if it's rescheduled.
return undefined;
}
} and then wherever I would use import {AsapScheduler} from "rxjs/internal/scheduler/AsapScheduler"
scheduled(new Subject(), new AsapScheduler(CustomAsapAction)) |
Fair enough, but we don't use AsapScheduler directly. It's being used in another library we have zero control over. |
We removed the |
This should be fixed as of rxjs@7.5.7, please update. |
Still doesn't work for our project after updating to 7.5.7. |
Not sure how helpful this is: In our case, some actions cause the AsapScheduler to flush and others don't (i.e. actions get added to the actions array, but never get automatically flushed out via their id). |
Still not working on 7.5.7, please see this StackBlitz: https://stackblitz.com/edit/rxjs-khv49a?file=index.ts |
@benlesh Please reopen |
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. |
We'll discuss this in next core team meeting again to confirm. |
/cc @benlesh . |
CORE TEAM: Needs to be fixed in v7 and v8. We'll likely be introducing new/better/smaller schedulers for v9. |
We are hitting the same issue, even with the latest 8 alpha at the time of writing, and this is blocking us from upgrading. don't really understand how this wasn't caught either through rx.js's tests or by piggybacking on other codebases to "e2e" test new rx.js versions. |
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: #6747 (comment) 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. |
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 runReproduction code
See the instructions in the stackblitz:
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 usedasapScheduler
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 worksReproduction 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
The text was updated successfully, but these errors were encountered: