Rxjs: Timeout can't take error as parameter

Created on 14 Apr 2017  路  6Comments  路  Source: ReactiveX/rxjs

RxJS version: 5.1.1

Code to reproduce:

            let sub = this.http.get(this.url + 'teams/' + teamId, {
                headers: this.headers
            })
                .retryWhen(error => error.delay(500))
                .timeout(2000, new Error('delay exceeded'))

Expected behavior: Should not throw compiler error when using error as a parameter for the timeout method of an observable.

Actual behavior: It throws an error saying that Argument of type 'Error' is not assignable to parameter of type 'IScheduler'.

Additional information: Angular v4

Most helpful comment

For people who stumble on this later, you can use .timeoutWith(2000, Observable.throw(new Error('delay exceeded'))) 馃槉

All 6 comments

@kwonoj how can I pass data into the timeout error?

@wbhob it is no longer supported to carry forward different error (or any other object) when timeout error is being thrown. If you really need to deliver error other than default timeouterror, you may need .catch() then rethrow by Observable.throw your custom error.

What does that look like (thanks for all your help by the way) @kwonoj

For people who stumble on this later, you can use .timeoutWith(2000, Observable.throw(new Error('delay exceeded'))) 馃槉

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chalin picture chalin  路  4Comments

samherrmann picture samherrmann  路  3Comments

benlesh picture benlesh  路  3Comments

jakovljevic-mladen picture jakovljevic-mladen  路  3Comments

cartant picture cartant  路  3Comments