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

introduce a remote allocator option: NoModifyURL #1184

Merged
merged 4 commits into from Oct 31, 2022

Conversation

ZekeLu
Copy link
Member

@ZekeLu ZekeLu commented Oct 26, 2022

The feature implemented by #817 makes chromedp not work with browserless. In order to address this issue, a new remote allocator option is introduced: chromedp.NoModifyURL. Usage:

ctx, cancel := chromedp.NewRemoteAllocator(context.Background(), "wss://chrome.browserless.io?token=YOUR-API-TOKEN", chromedp.NoModifyURL)

Fixes #972.

In headful mode, the remote debugging address will always be 127.0.0.1
or ::1, the command line option --remote-debugging-address is ignored.
See https://github.com/chromium/chromium/blob/106.0.5249.119/chrome/browser/devtools/remote_debugging_server.cc#L48-L58

In headless mode, the default remote debugging address is "localhost".
If --remote-debugging-address is specified, its value should be an IP
literal. See https://github.com/chromium/chromium/blob/106.0.5249.119/headless/app/headless_shell.cc#L750-L758

The ExecAllocator reads the remote debugging address from the stdout
of the browser. In all the cases listed above, the host of the address
can only be "localhost" or an IP. So forceIP is not needed.

This is a preparing step for further refactoring.
…or).Allocate

Because detectURL could fail. But there is not way to report the failure
in NewRemoteAllocator (except for panicking).

This is a preparing step for further refactoring.
Changes:

1. make it context aware.
2. make it return an error if it fails to modify the URL.
3. bypass resolution when the host is "localhost" or an IP address.
4. improve comments.
The remote allocator tries to modify the websocket debugger url passed
to it.

This behavior breaks browserless (https://www.browserless.io/). The
option NoModifyURL is introduced to address this issue.
@ZekeLu
Copy link
Member Author

ZekeLu commented Oct 26, 2022

@andyMrtnzP (from #990) and @AlexLoyola @joelgriffith @kotchuprik (from #972)

Sorry for the belated fix! Would you like to review this PR and give it a try? The commits are better to be reviewed one by one because each commit just focuses on one thing and is relatively small.

Thank you!

@andyMrtnzP
Copy link

Works like a charm!

@ZekeLu
Copy link
Member Author

ZekeLu commented Oct 31, 2022

Thank you for the feedback! I'm going to merge this PR.

@ZekeLu ZekeLu merged commit 19b37c1 into chromedp:master Oct 31, 2022
@ZekeLu ZekeLu deleted the remote-opt branch October 31, 2022 10:56
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.

Avoid modifying WSS URLs since parameters are dropped through the detectURL method
2 participants