From b6771ea7453dbcfb2d1775ba42f57f11edd89561 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Wed, 12 Apr 2017 10:21:07 -0700 Subject: [PATCH] [client-app] Fix unhandled rejection handling (fix ipc parse error) Summary: Previously, we were listening for unhanlded rejections on both the `window` and the `process`. However, the window handler didn't receive an error as a parameter, but rather a window event. When trying to report this event and sending it over IPC we would get an ipc parse error. This commit makes it so we correctly report the error instead of the window event. Test Plan: manual Reviewers: mark, halla Reviewed By: halla Differential Revision: https://phab.nylas.com/D4412 --- packages/client-app/src/nylas-env.es6 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/client-app/src/nylas-env.es6 b/packages/client-app/src/nylas-env.es6 index 94609ab90..8f992eb5b 100644 --- a/packages/client-app/src/nylas-env.es6 +++ b/packages/client-app/src/nylas-env.es6 @@ -277,7 +277,6 @@ export default class NylasEnvConstructor { originalError.stack = convertStackTrace(originalError.stack, sourceMapCache); return this.reportError(originalError, {url, line: newLine, column: newColumn}); }; - window.addEventListener("unhandledrejection", e => this.reportError(e)); process.on('uncaughtException', e => this.reportError(e)); @@ -293,7 +292,15 @@ export default class NylasEnvConstructor { if (this.inDevMode()) { error.stack = convertStackTrace(error.stack, sourceMapCache); } - return this.reportError(error); + this.reportError(error); + }); + + window.addEventListener('unhandledrejection', e => { + const error = e.detail.reason + if (this.inDevMode()) { + error.stack = convertStackTrace(error.stack, sourceMapCache); + } + this.reportError(error) }); if (this.inSpecMode() || (this.inDevMode() && !this.inBenchmarkMode())) {