Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Fix gray screen crash that might happen when gathering usage stats
Browse files Browse the repository at this point in the history
Reviewed By: jknoxville

Differential Revision: D26814271

fbshipit-source-id: bd857a42ae6b2528e42c96d0865ae2c532ea345f
  • Loading branch information
mweststrate authored and facebook-github-bot committed Mar 4, 2021
1 parent 05a7451 commit 67e87c2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions desktop/app/src/dispatcher/tracking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ipcRenderer, remote} from 'electron';
import {performance} from 'perf_hooks';
import {EventEmitter} from 'events';

import {Store} from '../reducers/index';
import {State, Store} from '../reducers/index';
import {Logger} from '../fb-interfaces/Logger';
import Client from '../Client';
import {
Expand Down Expand Up @@ -121,8 +121,19 @@ export default (store: Store, logger: Logger) => {
);
}

ipcRenderer.on('trackUsage', (_e, ...args: any[]) => {
const state = store.getState();
ipcRenderer.on('trackUsage', (event, ...args: any[]) => {
let state: State;
try {
state = store.getState();
} catch (e) {
// if trackUsage is called (indirectly) through a reducer, this will utterly die Flipper. Let's prevent that and log an error instead
console.error(
'trackUsage triggered indirectly as side effect of a reducer. Event: ',
event.type,
event,
);
return;
}
const {
selectedDevice,
selectedPlugin,
Expand Down

0 comments on commit 67e87c2

Please sign in to comment.