From 9ebc46b58e783527e2d8c2562ab7587ec02664f5 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Wed, 16 Nov 2016 20:32:05 -0800 Subject: [PATCH] fix(timeout): throw traceable TimeoutError (#2132) - create TimeoutError contain stacktrace nearby caller instead of scheduler --- src/operator/timeout.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); } }