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

Throttle goes crazy in sync source, sync notifier scenario with trailing: true #6058

Closed
benlesh opened this issue Feb 26, 2021 · 0 comments · Fixed by #6059
Closed

Throttle goes crazy in sync source, sync notifier scenario with trailing: true #6058

benlesh opened this issue Feb 26, 2021 · 0 comments · Fixed by #6059
Assignees
Labels
bug Confirmed bug

Comments

@benlesh
Copy link
Member

benlesh commented Feb 26, 2021

Originally reported here

Original Text (@OliverJAsh)

Another weird discovery: in v7.0.0-beta.10 this doesn't throw an error but it does still log 1 over 1000 times.

import * as Rx from "rxjs";
import { throttle } from "rxjs/operators";

const source = Rx.of(1).pipe(
  throttle(() => Rx.of(1), { leading: false, trailing: true })
);

source.subscribe(x => console.log(x));

https://stackblitz.com/edit/rxjs-compat-vswz6n

If someone can confirm this is not expected behaviour, I can try to send a PR with a test and a fix.

If I understand correctly, this is the expected behaviour as @josepot says:

If the source emits and completes synchronously, then I would expect for the operator to not capture any values during the durationSelector observable

So source should emit nothing and complete synchronously?


In RxJS v7 beta, the behaviour is different but still incorrect (at least in my mind): https://stackblitz.com/edit/rxjs-compat-mmjf6c. This never logs anything.

Ah, I believe this is because of this change: 4af0227. In my example the duration selector never emits anything, it only completes. That makes sense.

@benlesh benlesh added the bug Confirmed bug label Feb 26, 2021
@benlesh benlesh self-assigned this Feb 26, 2021
benlesh added a commit to benlesh/rxjs that referenced this issue Feb 26, 2021
…ing case

Resolves an edge case where if a user provided a synchronous source and a synchronous notifier, using a trailing behavior, the returned observable would get caught in a loop emitting the final value over and over again.

fixes: ReactiveX#6058
benlesh added a commit that referenced this issue Feb 26, 2021
…ing case (#6059)

Resolves an edge case where if a user provided a synchronous source and a synchronous notifier, using a trailing behavior, the returned observable would get caught in a loop emitting the final value over and over again.

fixes: #6058
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant