fix(core): invoke error handler outside of the Angular Zone (#18269)
In Node.JS console.log/error/warn functions actually resuls in a socket write which in turn is considered by Zone.js as an async task. This means that if there is any exception during change detection in a platform-server application the error handler will make the Angular Zone unstable which in turn will cause change detection to run on next tick and cause an infinite loop. It is also better to run the error handler outside of the Angular Zone in general on all platforms so that an error in the error handler itself doesn't cause an infinite loop. Fixes #17073, #7774. PR Close #18269
This commit is contained in:

committed by
Miško Hevery

parent
abee785821
commit
7ae7573bc8
@ -575,6 +575,14 @@ export function main() {
|
||||
|
||||
class MockConsole {
|
||||
res: any[][] = [];
|
||||
log(...args: any[]): void { this.res.push(args); }
|
||||
error(...args: any[]): void { this.res.push(args); }
|
||||
log(...args: any[]): void {
|
||||
// Logging from ErrorHandler should run outside of the Angular Zone.
|
||||
NgZone.assertNotInAngularZone();
|
||||
this.res.push(args);
|
||||
}
|
||||
error(...args: any[]): void {
|
||||
// Logging from ErrorHandler should run outside of the Angular Zone.
|
||||
NgZone.assertNotInAngularZone();
|
||||
this.res.push(args);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user