berstend / puppeteer-extra

💯 Teach puppeteer new tricks through plugins.
https://extra.community
MIT License
6.45k stars 740 forks source link

[Bug] "TypeError: page._client.send is not a function" when running npx extract-stealth-evasions #651

Closed decaffeinatedio closed 2 years ago

decaffeinatedio commented 2 years ago

Describe the bug When running npx extract-stealth-evasions on a variety of systems (PopOS 22 locally), I receive the error:

TypeError: page._client.send is not a function
    at Plugin.onPageCreated (/home/ian/.npm/_npx/352800/lib/node_modules/extract-stealth-evasions/node_modules/puppeteer-extra-plugin-stealth/evasions/user-agent-override/index.js:180:18)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Plugin._onTargetCreated (/home/ian/.npm/_npx/352800/lib/node_modules/extract-stealth-evasions/node_modules/puppeteer-extra-plugin/dist/index.cjs.js:496:21)

If I exclude the user-agent-override evasion, the command runs successfully.

Code Snippet

Versions

  System:
    OS: Linux 5.17 Pop!_OS 22.04 LTS
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 6.48 GB / 30.98 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 14.9.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.8 - /usr/local/bin/npm
Miosame commented 2 years ago

If I exclude the user-agent-override evasion, the command runs successfully.

Can you describe how you do that?

decaffeinatedio commented 2 years ago

@Miosame Sure can:

npx extract-stealth-evasions -e user-agent-override

Miosame commented 2 years ago

@decaffeinatedio does that remove the error for you entirely? or does it still happen at the first launch

oh I just noticed, you're launching it directly, the same thing happens on the stealth plugin, I wonder what the alternative is there

Found how you can do the same on regular stealth: https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth/evasions/user-agent-override

const StealthPlugin = require('puppeteer-extra-plugin-stealth')
const stealth = StealthPlugin()
// Remove this specific stealth plugin from the default set
stealth.enabledEvasions.delete('user-agent-override')
puppeteer.use(stealth)
aemla commented 2 years ago

Try to downgrade to puppeteer 14.3.0. It solved TypeError: page._client.send is not a function error for me.

MoKhajavi75 commented 2 years ago

Any updates?

berstend commented 2 years ago

This should now be fixed in the latest update

decaffeinatedio commented 2 years ago

Now working on my end, thanks @berstend !

MoKhajavi75 commented 2 years ago

Fixed in the new version!

cc. @decaffeinatedio Please close this issue

berstend commented 2 years ago

Thanks for confirming, closing this ticket now :)

adinvadim commented 2 years ago

Dont fix for me with 15.3.0 and ghost-cursor

Falling back to JS scroll method TypeError: page._client.send is not a function
berstend commented 2 years ago

@adinvadim ghost-cursor has nothing to do with our project, raise that issue with them: https://github.com/Xetera/ghost-cursor

edit, created a PR with them: https://github.com/Xetera/ghost-cursor/pull/62

alecellis1985 commented 2 years ago

const client = await page.target().createCDPSession(); await client .send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath: dir, }); tested in our production and it works fine

Lovely-Ruby commented 8 months ago

that is useful in 2024-02-19, thanks a lot