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

feat(launcher): add browserUrl option to puppeteer.connect #3558

Merged
merged 3 commits into from Jan 14, 2019

Conversation

lukaszfiszer
Copy link
Contributor

Fixes #3537

I will add documentation if the code is ok.

lib/Puppeteer.js Outdated
@@ -37,7 +37,7 @@ module.exports = class {
}

/**
* @param {!(Launcher.BrowserOptions & {browserWSEndpoint: string, transport?: !Puppeteer.ConnectionTransport})} options
* @param {!(Launcher.BrowserOptions & {browserWSEndpoint: string, browserUrl: string, transport?: !Puppeteer.ConnectionTransport})} options
Copy link
Collaborator

Choose a reason for hiding this comment

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

browserUrl?:

The question mark makes it optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we make both browserWSEndpoint and browserUrl optional then? You should pass one or another, but not both.

lib/Launcher.js Outdated
const {webSocketDebuggerUrl} = JSON.parse(data);
resolve(webSocketDebuggerUrl);
} catch (e) {
onGetWsEndpointError(e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need special error forwarding here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to display the same user-friendly error message both in case of network failure and JSON parsing failure. Example:

Error: Failed to fetch browser webSocket url from http://127.0.0.1:21222/: SyntaxError: Unexpected token < in JSON at position 0
    at onGetWsEndpointError (/Users/lf/Projects/puppeteer/lib/Launcher.js:413:12)
    at onGetWsEndpointDone (/Users/lf/Projects/puppeteer/lib/Launcher.js:408:7)
    at IncomingMessage.res.on (/Users/lf/Projects/puppeteer/lib/Launcher.js:426:25)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:139:11)
    at process._tickCallback (internal/process/next_tick.js:181:9)

…ional, refactor function names in getWSEndpoint
@lukaszfiszer
Copy link
Contributor Author

Added docs, made browserWSEndpoint and browserUrl optional, refactor event handler function names in getWSEndpoint. @JoelEinbinder @aslushnikov could you take a look?

[ConnectionTransport]: ../lib/WebSocketTransport.js "ConnectionTransport"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a final new line was added at the end of this file, conforming with .editorconfig

Copy link
Contributor

@aslushnikov aslushnikov left a comment

Choose a reason for hiding this comment

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

In it goes!

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.

None yet

3 participants