diff --git a/src/operator/timeout.ts b/src/operator/timeout.ts index 552ad56451..e69c786905 100644 --- a/src/operator/timeout.ts +++ b/src/operator/timeout.ts @@ -18,9 +18,10 @@ import { TimeoutError } from '../util/TimeoutError'; export function timeout(this: Observable, due: number | Date, errorToSend: any = null, scheduler: Scheduler = async): Observable { - let absoluteTimeout = isDate(due); - let waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due); - return this.lift(new TimeoutOperator(waitFor, absoluteTimeout, errorToSend, scheduler)); + const absoluteTimeout = isDate(due); + const waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due); + const error = errorToSend || new TimeoutError(); + return this.lift(new TimeoutOperator(waitFor, absoluteTimeout, error, scheduler)); } class TimeoutOperator implements Operator { @@ -96,6 +97,6 @@ class TimeoutSubscriber extends Subscriber { } notifyTimeout(): void { - this.error(this.errorToSend || new TimeoutError()); + this.error(this.errorToSend); } }