Skip to content

Commit

Permalink
cli: throw error if running x64 node on mac arm64 (GoogleChrome#14288)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored and alexnj committed Aug 24, 2022
1 parent ccacd91 commit 87f6647
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cli/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/* eslint-disable no-console */

import path from 'path';
import os from 'os';

import psList from 'ps-list';
import * as ChromeLauncher from 'chrome-launcher';
Expand Down Expand Up @@ -70,6 +71,18 @@ function parseChromeFlags(flags = '') {
* @return {Promise<ChromeLauncher.LaunchedChrome>}
*/
function getDebuggableChrome(flags) {
if (process.platform === 'darwin' && process.arch === 'x64') {
const cpus = os.cpus();
if (cpus[0].model.includes('Apple')) {
throw new Error(
'Launching Chrome on Mac Silicon (arm64) from an x64 Node installation results in ' +
'Rosetta translating the Chrome binary, even if Chrome is already arm64. This would ' +
'result in huge performance issues. To resolve this, you must run Lighthouse CLI with ' +
'a version of Node built for arm64. You should also confirm that your Chrome install ' +
'says arm64 in chrome://version');
}
}

return ChromeLauncher.launch({
port: flags.port,
ignoreDefaultFlags: flags.chromeIgnoreDefaultFlags,
Expand Down

0 comments on commit 87f6647

Please sign in to comment.