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
This commit is contained in:
Michel Weststrate
2020-03-24 06:42:44 -07:00
committed by Facebook GitHub Bot
parent 79141f5fd2
commit 0a8d8f44ff

View File

@@ -119,15 +119,23 @@ export default (store: Store, logger: Logger) => {
| typeof FlipperPlugin
| typeof FlipperDevicePlugin = pluginMap.get(pluginName);
if (persistingPlugin && persistingPlugin.getActiveNotifications) {
try {
const notifications = persistingPlugin.getActiveNotifications(
pluginStates[key],
);
store.dispatch(
setActiveNotifications({
notifications: persistingPlugin.getActiveNotifications(
pluginStates[key],
),
notifications,
client,
pluginId: pluginName,
}),
);
} catch (e) {
console.error(
'Failed to compute notifications for plugin ' + pluginName,
e,
);
}
}
}
});