mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: check if executablePath exists (#12201)
This commit is contained in:
parent
7bc5e0fb2d
commit
4ec0280080
@ -98,6 +98,12 @@ export abstract class ProductLauncher {
|
||||
|
||||
const launchArgs = await this.computeLaunchArguments(options);
|
||||
|
||||
if (!existsSync(launchArgs.executablePath)) {
|
||||
throw new Error(
|
||||
`Browser was not found at the configured executablePath (${launchArgs.executablePath})`
|
||||
);
|
||||
}
|
||||
|
||||
const usePipe = launchArgs.args.includes('--remote-debugging-pipe');
|
||||
|
||||
const onProcessExit = async () => {
|
||||
|
@ -13,7 +13,11 @@ import puppeteer from 'puppeteer-core';
|
||||
executablePath: 'node',
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.message.includes('Failed to launch the browser process')) {
|
||||
if (
|
||||
error.message.includes(
|
||||
'Browser was not found at the configured executablePath (node)'
|
||||
)
|
||||
) {
|
||||
process.exit(0);
|
||||
}
|
||||
console.error(error);
|
||||
|
@ -190,7 +190,9 @@ describe('Launcher specs', function () {
|
||||
}).catch(error => {
|
||||
return (waitError = error);
|
||||
});
|
||||
expect(waitError.message).toContain('Failed to launch');
|
||||
expect(waitError.message).toBe(
|
||||
'Browser was not found at the configured executablePath (random-invalid-path)'
|
||||
);
|
||||
});
|
||||
it('userDataDir option', async () => {
|
||||
const userDataDir = await mkdtemp(TMP_FOLDER);
|
||||
@ -615,6 +617,20 @@ describe('Launcher specs', function () {
|
||||
});
|
||||
expect(error.message).toContain('either pipe or debugging port');
|
||||
});
|
||||
|
||||
it('throws an error if executable path is not valid with pipe=true', async () => {
|
||||
const options = {
|
||||
executablePath: '/tmp/does-not-exist',
|
||||
pipe: true,
|
||||
};
|
||||
let error!: Error;
|
||||
await launch(options).catch(error_ => {
|
||||
return (error = error_);
|
||||
});
|
||||
expect(error.message).toContain(
|
||||
'Browser was not found at the configured executablePath (/tmp/does-not-exist)'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Puppeteer.launch', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user