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

fix(proxy): fix requests with proxies #1408

Merged
merged 2 commits into from
Dec 15, 2020
Merged

fix(proxy): fix requests with proxies #1408

merged 2 commits into from
Dec 15, 2020

Conversation

Doridian
Copy link
Collaborator

Description

As you might notice, I had to fork puppeteer-page-proxy. The fix I applied has already been PR'd upstream for several months and the library seems unmaintained currently (but there is no viable alternative either).
Other than that, I also added the *.proxies files to gitignore and fixed a problem where adblock would "randomly" disable request interception.

Testing

New dependencies

@Doridian
Copy link
Collaborator Author

Fixes #1394

Comment on lines +208 to +210
if (prop === 'setRequestInterception') {
return noop;
}
Copy link
Owner

Choose a reason for hiding this comment

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

I suppose the important part here is that you're returning an empty function rather than a value, correct?

Why is this important?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The adblock plugin will sometimes, for various reasons, call setRequestInterception(false) because it thinks it is the authority on request listeners (which, due to us injecting proxies with that, too, it is not).
All this does is give the adblock plugin a function to call that will not error and simply does nothing at all, so it can be happy thinking it disabled request listeners, and the proxy plugin can be happy still using them.

Copy link
Owner

Choose a reason for hiding this comment

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

Aha, I see! Interesting. Do you think it would be worth mentioning making a ticket about on their repos?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jef Not really. The way puppeteer works, only one on-request listener is possible. The Proxy thing we do is a hack, and for sure not an expected use case of anything. Now if puppeteer ever supports multiple on-request listeners, then that might be considered an issue.

Copy link
Owner

@jef jef Dec 15, 2020

Choose a reason for hiding this comment

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

Wait, I'm sorry. I'm misunderstanding the situation. You did make a fork of package and you fixed that issue. As for ghostery/adblocker#1495, that isn't an issue for that library, yet an issue with the original puppeteer-page-proxy.

I'm I understanding this correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jef The issue with adblock purely arises because we need multiple things that employ request listeners, which puppeteer does not support in any way. So we hack around and "fake" the Page object the adblocker sees to be able to do it. Of course adblock has no way of expecting to get a proxied page object, so this is not a bug on their end at all, we just do something puppeteer cannot do.

@jef jef changed the title fix(proxy): Fix requests with proxies fix(proxy): fix requests with proxies Dec 15, 2020
@jef jef merged commit f65df4c into jef:main Dec 15, 2020
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.

2 participants