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

Commit

Permalink
Don't crash server if chrome fails to open
Browse files Browse the repository at this point in the history
Summary:
## Context
Flipper server was shutting itself down because it couldn't open chrome. This isn't a fatal exception though.

## Changes
* Catch the exception and log

Differential Revision: D55405348

fbshipit-source-id: edc055ee7e7c67db40a3d83bff0e88e89fe7bd5d
  • Loading branch information
AriaFallah authored and facebook-github-bot committed Mar 27, 2024
1 parent 23a0407 commit 93c41ab
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions desktop/flipper-server/src/utils/openUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ export async function openUI(preference: UIPreference, port: number) {

console.info(`[flipper-server] Go to: ${url.toString()}`);

open(url.toString(), {app: {name: open.apps.chrome}});

tracker.track('server-open-ui', {
browser: true,
hasToken: token?.length != 0,
});
try {
const process = await open(url.toString(), {
app: {name: open.apps.chrome},
});
await new Promise((resolve, reject) => {
process.on('spawn', resolve);
process.on('error', reject);
});
tracker.track('server-open-ui', {
browser: true,
hasToken: token?.length != 0,
});
} catch (err: unknown) {
console.error('[flipper-server] Failed to open browser', err);
}
};

if (preference === UIPreference.Browser) {
Expand Down

0 comments on commit 93c41ab

Please sign in to comment.