-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(error): Make rx access Error.stack lazily
Error.stack can potentially trigger expensive prepareStackTrace calls, Observable.timeout would crate a TimeoutError on use, before the actual error occurs. This eases tracing the location of the timeout, but with the current implementation, slows down the application when using many .timeout operators throughout the code.
- Loading branch information
1 parent
d2a32f9
commit dfcf919
Showing
4 changed files
with
42 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
/** | ||
* An error thrown when duetime elapses. | ||
* | ||
* @see {@link timeout} | ||
* | ||
* @class TimeoutError | ||
*/ | ||
export class TimeoutError extends Error { | ||
constructor() { | ||
const err: any = super('Timeout has occurred'); | ||
(<any> this).name = err.name = 'TimeoutError'; | ||
(<any> this).stack = err.stack; | ||
(<any> this).message = err.message; | ||
} | ||
} | ||
/** | ||
* An error thrown when duetime elapses. | ||
* | ||
* @see {@link timeout} | ||
* | ||
* @class TimeoutError | ||
*/ | ||
export class TimeoutError extends Error { | ||
private err: Error; | ||
|
||
constructor() { | ||
const err: any = super('Timeout has occurred'); | ||
this.err = err; | ||
(<any> this).name = err.name = 'TimeoutError'; | ||
(<any> this).message = err.message; | ||
} | ||
|
||
get stack() { | ||
return this.err.stack; | ||
} | ||
} |