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

asapScheduler: Scheduling inside of an executing action only works once #7196

Closed
benlesh opened this issue Feb 28, 2023 · 2 comments
Closed
Assignees

Comments

@benlesh
Copy link
Member

benlesh commented Feb 28, 2023

Originally reported here: #6747 (comment)

Failing test:

  it('scheduling inside of an executing action more than once should work', (done) => {
    const results: any[] = [];

    asapScheduler.schedule(() => {
      results.push(1)
      asapScheduler.schedule(() => results.push(2));
      asapScheduler.schedule(() => results.push(3));
    });

    setTimeout(() => {
      // This should always fire after two recursively scheduled microtasks.
      expect(results).to.deep.equal([1, 2, 3]);
      done() 
    })
  })
@benlesh benlesh self-assigned this Feb 28, 2023
benlesh added a commit to benlesh/rxjs that referenced this issue Feb 28, 2023
…g flush

Fixes an issue where trying to share a microtask cause the scheduler to trip over itself. Instead, each scheduled item will get its own microtask.

resolves ReactiveX#7196
trxcllnt added a commit to trxcllnt/rxjs that referenced this issue Feb 28, 2023
Fixes an issue where trying to share a microtask cause the scheduler to trip over itself.

resolves ReactiveX#7196
benlesh pushed a commit that referenced this issue Mar 1, 2023
…sh (#7198)

Fixes an issue where trying to share a microtask cause the scheduler to trip over itself.

resolves #7196
@benlesh benlesh closed this as completed in 414a692 Mar 1, 2023
@Dedicatus546
Copy link
Contributor

it seems that animateFrameScheduler has the same problem, its source code is similar to asapScheduler , but when i execute the follow code:

animationFrameScheduler.schedule(() => {
  results.push(1);
  animationFrameScheduler.schedule(() => results.push(2));
  animationFrameScheduler.schedule(() => results.push(3));
  animationFrameScheduler.schedule(() => results.push(4));
  animationFrameScheduler.schedule(() => results.push(5));
});

it can't get the results with [1, 2, 3, 4, 5]

image

but the native method is work well.

image

is it a bug ?

@Blafasel3
Copy link

it seems that animateFrameScheduler has the same problem, its source code is similar to asapScheduler , but when i execute the follow code:

animationFrameScheduler.schedule(() => {
  results.push(1);
  animationFrameScheduler.schedule(() => results.push(2));
  animationFrameScheduler.schedule(() => results.push(3));
  animationFrameScheduler.schedule(() => results.push(4));
  animationFrameScheduler.schedule(() => results.push(5));
});

it can't get the results with [1, 2, 3, 4, 5]

image

but the native method is work well.

image

is it a bug ?

It seems our team ran into this issue regarding the animationFrameScheduler as well. We are using the ng-scrollbar library and when scrolling to an particular element, it just happens sometimes that the callback scheduled in the following line https://github.com/MurhafSousli/ngx-scrollbar/blob/master/projects/ngx-scrollbar/smooth-scroll/src/smooth-scroll-manager.ts#L136 is never executed. It just seems to die and only hard refreshing (CTRL+F5) the page actually fixes the issue.

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

3 participants