Skip to content

Commit

Permalink
Add default browser fallback to debugger launch flow (#44673)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44673

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D57726648

fbshipit-source-id: 66eaab1dd0d53fe2befb3dc96d5deb426b86e3e7
  • Loading branch information
huntie authored and pull[bot] committed Jun 17, 2024
1 parent 167912d commit 5610938
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/dev-middleware/src/utils/DefaultBrowserLauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {BrowserLauncher} from '../types/BrowserLauncher';
const {spawn} = require('child_process');
const ChromeLauncher = require('chrome-launcher');
const {Launcher: EdgeLauncher} = require('chromium-edge-launcher');
const open = require('open');

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

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

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

0 comments on commit 5610938

Please sign in to comment.