fix: warn about launch Chrome using Node x64 on arm64 Macs (#11471)

This commit is contained in:
Alex Rudenko 2023-11-30 14:26:49 +01:00 committed by GitHub
parent 50695ec4d0
commit 957a8293bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,7 @@
*/ */
import {mkdtemp} from 'fs/promises'; import {mkdtemp} from 'fs/promises';
import os from 'os';
import path from 'path'; import path from 'path';
import { import {
@ -64,6 +65,26 @@ export class ChromeLauncher extends ProductLauncher {
); );
} }
if (
this.puppeteer.configuration.logLevel === 'warn' &&
process.platform === 'darwin' &&
process.arch === 'x64'
) {
const cpus = os.cpus();
if (cpus[0]?.model.includes('Apple')) {
console.warn(
[
'\x1B[1m\x1B[43m\x1B[30m',
'Degraded performance warning:\x1B[0m\x1B[33m',
'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 Puppeteer with',
'a version of Node built for arm64.',
].join('\n ')
);
}
}
return super.launch(options); return super.launch(options);
} }