From 19271d16ffe7dd0032d24f9dbf65ff4dc41fe970 Mon Sep 17 00:00:00 2001 From: Igor O Date: Tue, 4 Apr 2023 14:54:43 -0700 Subject: [PATCH] prevent infinity loop on logging unhandled error (#2147) --- src/errors/unhandledErrorHandler.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/errors/unhandledErrorHandler.ts b/src/errors/unhandledErrorHandler.ts index 8c33da94a..b36e3fe0e 100644 --- a/src/errors/unhandledErrorHandler.ts +++ b/src/errors/unhandledErrorHandler.ts @@ -8,10 +8,18 @@ export class UnhandledErrorHandler { } public handlerError(event: ErrorEvent): void { - this.logger.trackError(event.error); + try { + this.logger.trackError(event.error); + } catch (error) { + console.error(`Unable to log event.error: ${event.error} - Error:`, error); + } } public handlerPromiseRejection(event: PromiseRejectionEvent): void { - this.logger.trackError(event.reason); + try { + this.logger.trackError(event.reason); + } catch (error) { + console.error(`Unable to log Promise Rejection event.reason: ${event.reason} - Error:`, error); + } } } \ No newline at end of file