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

debounce does not handle scalar observables correctly #3232

Closed
Medo42 opened this issue Jan 18, 2018 · 1 comment · Fixed by GulajavaMinistudio/rxjs#90 or Xenira/Shashki#66
Closed

Comments

@Medo42
Copy link

Medo42 commented Jan 18, 2018

RxJS version:
5.5.2, but the offending code is unchanged in 5.5.6

Code to reproduce:

// Not working
Observable.interval(100).pipe(
    debounce(i => Observable.of(0))
).subscribe(console.log);

// Working
Observable.interval(100).pipe(
    debounce(i => Observable.timer(0))
).subscribe(console.log);

Expected behavior:

The debounce should act as a no-op.

Actual behavior:

There is an error:

ERROR TypeError: Cannot read property 'closed' of null
    at DebounceSubscriber._tryNext (debounce.js:102)

The line number refers to 5.5.2, it is this line: https://github.com/ReactiveX/rxjs/blob/5.5.6/src/operators/debounce.ts#L108

Additional information:

The call to subscribeToResult returns null if no subscription is necessary because the value can be immediately obtained, as in this case of a simple "scalar" observable. debounce should handle this return value properly.

The example code is useless of course. My actual use case only returned such an Observable in one case, depending on the value passed in. It is for a loading bar which should only show after at least 200ms of activity, but should be hidden immediately once activity stops.

cartant added a commit to cartant/rxjs that referenced this issue Jan 19, 2018
acutmore pushed a commit to youviewtv/rxjs-5 that referenced this issue Jan 23, 2018
* test(debounce): add failing scalar selector test

* fix(debounce): support scalar selectors

Closes ReactiveX#3232

* test(debounce): rename and comment test

(cherry picked from commit 1548393)
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant