From 0a8d8f44fff2fed3a4adbe3074a629de47c16e48 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 24 Mar 2020 06:42:44 -0700 Subject: [PATCH] Make sure notication computation can't crash the dispatch Summary: Collecting notifications is done in the store.subscribe. If this throws however, the entire original dispatch throws (really Redux?!). So added a try catch around collecting notifications. This stops plugins from crashing while processing the queue (in fact this could happen during any Redux dispatch). Will look into a more robust mechanism in the future I suspect this also fixes the hanging graphQL issue Reviewed By: jknoxville Differential Revision: D20619226 fbshipit-source-id: 2f6b8e13a5c884dd63b6963d317474a2abf0725c --- desktop/app/src/dispatcher/notifications.tsx | 26 +++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/desktop/app/src/dispatcher/notifications.tsx b/desktop/app/src/dispatcher/notifications.tsx index 796602198..41bdc8f3d 100644 --- a/desktop/app/src/dispatcher/notifications.tsx +++ b/desktop/app/src/dispatcher/notifications.tsx @@ -119,15 +119,23 @@ export default (store: Store, logger: Logger) => { | typeof FlipperPlugin | typeof FlipperDevicePlugin = pluginMap.get(pluginName); if (persistingPlugin && persistingPlugin.getActiveNotifications) { - store.dispatch( - setActiveNotifications({ - notifications: persistingPlugin.getActiveNotifications( - pluginStates[key], - ), - client, - pluginId: pluginName, - }), - ); + try { + const notifications = persistingPlugin.getActiveNotifications( + pluginStates[key], + ); + store.dispatch( + setActiveNotifications({ + notifications, + client, + pluginId: pluginName, + }), + ); + } catch (e) { + console.error( + 'Failed to compute notifications for plugin ' + pluginName, + e, + ); + } } } });