From f12144be38cf1d1ffbdbb045daf16fe2756ad4b6 Mon Sep 17 00:00:00 2001 From: John Knox Date: Mon, 25 Feb 2019 09:28:31 -0800 Subject: [PATCH] Fix CRASH: undefined undefined bug Summary: Display "crashes" as plugin errors when they don't include the expected crash attributes. Plugins can respond to a `call()` with success or error. If error, then they can provide an arbitrary json object. These errors go through the same code as crash reports for the crash reporter plugin, but they don't necessarily contain the expected attributes. When they don't display them as a plugin error, and stringify the whole object. It would be better to distinguish these properly and highlight that they aren't crashes, in the crash reporter, but that's a bigger task. This stops them being shown as "undefined undefined". Reviewed By: xiphirx Differential Revision: D14207907 fbshipit-source-id: 8ba357fbe681a40cd671510a187073e4cbfa2184 --- src/Client.js | 17 ++++++++++++----- src/plugins/layout/layout2/index.js | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Client.js b/src/Client.js index 77359bba2..f5b935fdd 100644 --- a/src/Client.js +++ b/src/Client.js @@ -57,15 +57,22 @@ const handleError = (store: Store, deviceSerial: ?string, error: ErrorType) => { ...crashReporterPlugin.defaultPersistedState, ...store.getState().pluginStates[pluginKey], }; + const isCrashReport: boolean = Boolean(error.name || error.message); + const payload = isCrashReport + ? { + name: error.name, + reason: error.message, + callstack: error.stacktrace, + } + : { + name: 'Plugin Error', + reason: JSON.stringify(error), + }; // $FlowFixMe: We checked persistedStateReducer exists const newPluginState = crashReporterPlugin.persistedStateReducer( persistedState, 'flipper-crash-report', - { - name: error.name, - reason: error.message, - callstack: error.stacktrace, - }, + payload, ); if (persistedState !== newPluginState) { store.dispatch( diff --git a/src/plugins/layout/layout2/index.js b/src/plugins/layout/layout2/index.js index 26eb20267..05d3f8379 100644 --- a/src/plugins/layout/layout2/index.js +++ b/src/plugins/layout/layout2/index.js @@ -16,6 +16,7 @@ import { Link, Glyph, DetailSidebar, + SidebarExtensions, } from 'flipper'; import Inspector from './Inspector'; import ToolbarIcon from './ToolbarIcon'; @@ -193,6 +194,7 @@ export default class Layout extends FlipperPlugin { element={element} onValueChanged={this.onDataValueChanged} logger={this.props.logger} + extensions={SidebarExtensions} />