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

The timeout() operator throws error prematurely #2579

Closed
martinsik opened this issue Apr 25, 2017 · 3 comments
Closed

The timeout() operator throws error prematurely #2579

martinsik opened this issue Apr 25, 2017 · 3 comments
Labels
bug Confirmed bug

Comments

@martinsik
Copy link
Contributor

martinsik commented Apr 25, 2017

RxJS version: 5.3.0

It seems like after the most recent changes in 5.3.0 the timeout() operator works differently. But I don't know whether this is intentional or not since it's not listed under either "Features" nor "Breaking Changes" in the change log.

Code to reproduce:

Observable
  .range(0, 10)
  .concatMap(val => Observable.of(val).delay(val >= 3 ? 5000 : 1000))
  .timeout(2000)
  .subscribe(
    val => console.log('next', val),
    err => console.log('error', err)
  );

First three items are delayed by 1 second while the fourth item is delayed by 5 seconds.

Expected behavior:

next 0
next 1
next 2
error { TimeoutError: Timeout has occurred
    at TimeoutError.Error (native)
...
  message: 'Timeout has occurred' }

Actual behavior:

next 0
error { TimeoutError: Timeout has occurred
    at TimeoutError.Error (native)
...
  message: 'Timeout has occurred' }

Additional information:

Only 5.3.0 is affected. I checked both 5.2.0 and 4.1.0 and in both cases it work as shown in Expected behavior. Also it looks like this situation is already tested: https://github.com/ReactiveX/rxjs/blob/master/spec/operators/timeout-spec.ts#L89

Demos:

RxJS 5.3.0: https://jsbin.com/wemuzuc/5/edit?html,js,console
RxJS 5.2.0: https://jsbin.com/nedagox/4/edit?html,js,console
RxJS 4.1.0: https://jsbin.com/ganofon/2/edit?html,js,console

@kwonoj
Copy link
Member

kwonoj commented Apr 25, 2017

gut guess (without any verification), maybe it's related to 3e9d529 **timeout: Cancels scheduled timeout, if no longer needed**? it has changed internals of timeout operator bit.

@trxcllnt
Copy link
Member

@martinsik thanks for filing this issue. I've submitted a fix in PR #2580. This is pretty serious, so we'll see about getting a patch release out soon.

@kwonoj kwonoj added the bug Confirmed bug label May 2, 2017
@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
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

3 participants