-
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
feat(launcher): add browserUrl option to puppeteer.connect #3558
feat(launcher): add browserUrl option to puppeteer.connect #3558
Conversation
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 |
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.
browserUrl?:
The question mark makes it optional.
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.
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); |
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 don't think we need special error forwarding here.
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.
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
Added docs, made |
[ConnectionTransport]: ../lib/WebSocketTransport.js "ConnectionTransport" |
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.
a final new line was added at the end of this file, conforming with .editorconfig
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.
In it goes!
Fixes #3537
I will add documentation if the code is ok.