-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Conversation
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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
bf9f523
to
33513c6
Compare
@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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the Chrome
There was a problem hiding this comment.
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}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Chrome
This patch:
Fixes #363.