Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launcher: add timeout to chrome launching #434

Merged
merged 4 commits into from
Aug 21, 2017

Conversation

aslushnikov
Copy link
Contributor

This patch:

  • adds 30s timeout for chromium to report the browser target url.
  • adds cleanup logic for main process SIGINT signal.

Fixes #363.

lib/Launcher.js Outdated

function onTimeout() {
cleanup();
reject(new Error('Failed to connect to chrome! The only chrome revision guaranteed to work is r' + ChromiumRevision));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we mention that it failed because of the timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lib/Launcher.js Outdated
helper.addEventListener(rl, 'close', onClose),
helper.addEventListener(chromeProcess, 'exit', onClose)
];
let timeout = setTimeout(onTimeout, 30 * 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make this optional. I can imagine some crazy cloud setup where 30 seconds to connect might not be unreasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Introduced "timeout" option to launching

This patch:
- adds 30s timeout for chromium to report the browser target url.
- adds cleanup logic for main process SIGINT signal.

Fixes puppeteer#363.
@aslushnikov
Copy link
Contributor Author

@JoelEinbinder addressed comments, please take another look!

docs/api.md Outdated
@@ -158,6 +158,8 @@ This methods attaches Puppeteer to an existing Chromium instance.
- `executablePath` <[string]> Path to a Chromium executable to run instead of bundled Chromium. If `executablePath` is a relative path, then it is resolved relative to [current working directory](https://nodejs.org/api/process.html#process_process_cwd).
- `slowMo` <[number]> Slows down Puppeteer operations by the specified amount of milliseconds. Useful so that you can see what is going on.
- `args` <[Array]<[string]>> Additional arguments to pass to the Chromium instance. List of Chromium flags can be found [here](http://peter.sh/experiments/chromium-command-line-switches/).
- `handleSIGINT` <[boolean]> Close chrome process on Ctrl-C. Defaults to `true`.
- `timeout` <[number]> Maximum time in milliseconds to wait for chrome instance to start. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Chrome

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

lib/Launcher.js Outdated

function onTimeout() {
cleanup();
reject(new Error(`Timed out after ${timeout} ms while trying to connect to chrome! The only chrome revision guaranteed to work is r${ChromiumRevision}`));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chrome

@aslushnikov aslushnikov merged commit 271fd09 into puppeteer:master Aug 21, 2017
@aslushnikov aslushnikov deleted the timeout-launch branch August 22, 2017 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants