-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Fixes #750 - Throw error with stack trace when calling launch with an… #751
Fixes #750 - Throw error with stack trace when calling launch with an… #751
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
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.
Good CL, thank you!
lib/Launcher.js
Outdated
@@ -173,4 +176,14 @@ function waitForWSEndpoint(chromeProcess, timeout) { | |||
}); | |||
} | |||
|
|||
function validateExecutablePath(chromeExecutable) { |
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.
let's add jsdoc:
/**
* @param {string} chromeExecutable
* @return {!Promise}
*/
test/test.js
Outdated
@@ -106,6 +106,12 @@ describe('Browser', function() { | |||
await neverResolves; | |||
expect(error.message).toContain('Protocol error'); | |||
})); | |||
it('should reject if executable path is invalid', SX(async function() { | |||
let waitError = null; | |||
const launchOptions = Object.assign({ defaultBrowserOptions }, { executablePath: 'random-invalid-path' }); |
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.
you want to extend default options with executable path:
const launchOptions = Object.assign({ executablePath: 'random-invalid-path' }, defaultBrowserOptions);
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 made a small change, but I don't think we should have { executablePath: ... }
as the first argument to Object.assign(...)
because if process.env.CHROME
is supplied, then the executablePath
supplied in Object.assign(...)
will be overridden causing this test to fail.
const options = Object.assign({}, defaultBrowserOptions, {executablePath: 'random-invalid-path'});
https://github.com/GoogleChrome/puppeteer/pull/751/files#diff-c1129c8b045390789fa8ff62f2c6b4a9R111
9e0fc1f
to
4d88574
Compare
@aslushnikov Thanks for the feedback. I made the changes and squashed. |
The |
@JoelEinbinder You're right. I will make the changes soon. Thanks. |
Hey, so I was looking at attaching an static async launch(options) {
...
const chromeProcess = childProcess.spawn(chromeExecutable, chromeArguments, {detached: true});
await new Promise((resolve, reject) => {
let timeout = setTimeout(resolve, 1000);
chromeProcess.on('error', () => {
clearTimeout(timeout);
reject(new Error(`Error launching Chromium process with executable path "${chromeExecutable}"`));
});
});
...
} I don't really like the idea of introducing a timer, but I'm not sure what the best way of getting around it is. We could simply just Thoughts @aslushnikov @JoelEinbinder? |
You can race |
Thanks @JoelEinbinder. Sounds good. I will have the fix up soon. |
@austinkelleher any updates on this? |
Hey, @aslushnikov. I apologize for the delay on PR feedback. Got caught up in some other things. Should be able to get to this later today. |
@austinkelleher thanks and no rush, I was mostly curious if you still have interest in this PR. |
4d88574
to
725fc71
Compare
Whoops I need to make a few more changes. Hold on. |
…h with an invalid executablePath option.
725fc71
to
aa0de01
Compare
@aslushnikov @JoelEinbinder Thanks again for the feedback. I've addressed them all. |
@aslushnikov @JoelEinbinder Can you please review my changes? Thanks! |
@austinkelleher I apologize for the long reply, I'm currently traveling. Codewise, I think this solution is a little too involved. It should be enough to catch the 'error' event on the chrome process - check out the #863. |
Closing in favor of #863 |
… invalid executablePath option.