Skip to content

Commit 5610938

Browse files
huntiepull[bot]
authored andcommitted
Add default browser fallback to debugger launch flow (#44673)
Summary: Pull Request resolved: #44673 Changelog: [Internal] Reviewed By: hoxyq Differential Revision: D57726648 fbshipit-source-id: 66eaab1dd0d53fe2befb3dc96d5deb426b86e3e7
1 parent 167912d commit 5610938

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

packages/dev-middleware/src/utils/DefaultBrowserLauncher.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {BrowserLauncher} from '../types/BrowserLauncher';
1414
const {spawn} = require('child_process');
1515
const ChromeLauncher = require('chrome-launcher');
1616
const {Launcher: EdgeLauncher} = require('chromium-edge-launcher');
17+
const open = require('open');
1718

1819
/**
1920
* Default `BrowserLauncher` implementation which opens URLs on the host
@@ -31,15 +32,15 @@ const DefaultBrowserLauncher: BrowserLauncher = {
3132
// Locate Chrome installation path, will throw if not found
3233
chromePath = ChromeLauncher.getChromePath();
3334
} catch (e) {
35+
// Fall back to Microsoft Edge
3436
chromePath = EdgeLauncher.getFirstInstallation();
37+
}
3538

36-
if (chromePath == null) {
37-
throw new Error(
38-
'Unable to find a browser on the host to open the debugger. ' +
39-
'Supported browsers: Google Chrome, Microsoft Edge.\n' +
40-
url,
41-
);
42-
}
39+
if (chromePath == null) {
40+
// Fall back to default browser - the frontend will warn if the browser
41+
// is not supported.
42+
await open(url);
43+
return;
4344
}
4445

4546
const chromeFlags = [`--app=${url}`, '--window-size=1200,600'];

0 commit comments

Comments
 (0)