-
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-handling): add deprecated sync error handling behind a flag
Given the LARGE number of people that seem to be using bad patterns like wrapping subscribe calls in a try catch, we're going to readd the synchronous error throwing behind a config flag during transition.
- Loading branch information
Showing
8 changed files
with
156 additions
and
29 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,8 +1,16 @@ | ||
import { Observer } from './types'; | ||
import { config } from './config'; | ||
import { hostReportError } from './util/hostReportError'; | ||
|
||
export const empty: Observer<any> = { | ||
closed: true, | ||
next(value: any): void { /* noop */}, | ||
error(err: any): void { throw err; }, | ||
error(err: any): void { | ||
if (config.useDeprecatedSynchronousErrorHandling) { | ||
throw err; | ||
} else { | ||
hostReportError(err); | ||
} | ||
}, | ||
complete(): void { /*noop*/ } | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Throws an error on another job so that it's picked up by the runtime's | ||
* uncaught error handling mechanism. | ||
* @param err the error to throw | ||
*/ | ||
export function hostReportError(err: any) { | ||
setTimeout(() => { throw err; }); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} |
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
Just curious of the decision to throw in a timeout instead of scheduling a microtask