-
-
Notifications
You must be signed in to change notification settings - Fork 741
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
Request interception with multiple plugins enabled #91
Comments
In the above code, everything runs fine if I disable either "puppeteer-extra-plugin-stealth" or "puppeteer-extra-plugin-block-resources". I do not need to disable both to have it run fine. |
Hmm, damn - I actually went to great length to avoid that :-/ You have two options until I fix that (I'm busy the next days so the fix won't be as quick as usual): const PluginStealth = require("puppeteer-extra-plugin-stealth");
const pluginStealth = PluginStealth()
pluginStealth.enabledEvasions.delete('accept-language')
puppeteer.use(pluginStealth) Or use an older verison ( |
The issue is in the new I thought I can hack around that by monkey patching things but it seems I need to do this more robust. |
Disabling |
I just released a hotfix to disable New version: |
is there a way to use the adblocker plugin alongside my own list of urls that I want to block ?
|
@SBerkovic Regular Puppeteer only allows a single interceptor to modify requests or allow them to signal continuation/abortion (which is bad for plugin systems like If I cannot hook into high-level pptr functions I'm thinking about intercepting the raw Chrome Devtools Protocol messages to make this modifications transparently to puppeteer :) |
Another potential solution would be to patch the EventEmitter in pptr to run listeners in sequence. |
It's a bit more tricky than I thought. My idea is to not require the user to do anything differently but keep their request interception code compatible. There are some UX issues I need to figure out, example:
I could add behavior that when the user is not doing Hmmmm. |
I'm running into the same issue, but I'm on v2.4.5. I'm running stealth, recaptcha, and adblocker plugins. If I disable the adblocker, the issues go away. If I enable adblocker and disable the others, the issue persists. |
Yup, the adblocker is the only major plugin left using requestInterception (after merging in #104). Unfortunately it's a bit tricky to fix, as puppeteer (and the underlying CDP message flow) doesn't expect multiple entities to be interested in using that functionality. 😄 My earlier optimistic monkey patching didn't hold up to scrutiny so I need to do it more properly. That would probably mean to move the event listener stuff from the base plugin to the puppeteer shim, as we need that birds eye view to add a listener that's always the last one (to handle .continue/.abort as mentioned in my earlier comment). Definitely a bit more juicy of a challenge that will take a while longer to implement (though nothing that cannot be fixed). Realistically I won't have the time to tackle this within the next 2 weeks. For the time being: If you need to intercept requests in your own code I advise to not use the adblocker plugin, until this is fixed. |
Is this advice still valid? What is the correct way to intercept requests now? |
In case someone is in my same use case, removing the handler first work (I also left a comment on puppeteer issue 5334, with more details). Calling |
I think the underlying issue is similar to #90 but there is another error that comes up and I think applies for more cases.
Running the code above produces two errors (but multiple times, presumably for every request).
The text was updated successfully, but these errors were encountered: