Skip to content

Commit

Permalink
fix: check if executablePath exists
Browse files Browse the repository at this point in the history
Closes #12025
  • Loading branch information
OrKoN committed Apr 3, 2024
1 parent d345055 commit 49ff86c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/puppeteer-core/src/node/ProductLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
14 changes: 14 additions & 0 deletions test/src/launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,20 @@ describe('Launcher specs', function () {
});
expect(error.message).toContain('either pipe or debugging port');
});

it('throws an error if executable path is not valid', 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 () {
Expand Down

0 comments on commit 49ff86c

Please sign in to comment.