puppeteer-extra: [Bug] TypeError: utils.forOwn is not a function
Hi, I’m running into this strange bug when using puppeteer-extra, puppeteer-extra-plugin-stealth with Typescript and the Serverless Framework. I will describe my setup and bug encountered below. I’ve tried a few things such as changing from puppeteer-core to puppeteer, but didn’t have any luck. I’m not sure if I missed anything obvious. Thanks for the help in advance!
The full error message is below. The error throws when calling puppeteerExtra.use(StealthPlugin());. I tried other plugins such as puppeteer-extra-plugin-adblocker and the error persists so I don’t think it’s the issue with a specific plugin.
✖ utils.forOwn is not a function
✖ TypeError: utils.forOwn is not a function
at cloneObjectDeep (/Users/leigong/git/friday/lambda/node_modules/merge-deep/node_modules/clone-deep/index.js:27:11)
at cloneDeep (/Users/leigong/git/friday/lambda/node_modules/merge-deep/node_modules/clone-deep/index.js:16:14)
at mergeDeep (/Users/leigong/git/friday/lambda/node_modules/merge-deep/index.js:19:16)
at new PuppeteerExtraPlugin (/Users/leigong/git/friday/lambda/node_modules/puppeteer-extra-plugin/src/index.ts:77:18)
at new StealthPlugin2 (/Users/leigong/git/friday/lambda/node_modules/puppeteer-extra-plugin-stealth/index.js:74:5)
at defaultExport (/Users/leigong/git/friday/lambda/node_modules/puppeteer-extra-plugin-stealth/index.js:172:31)
at Object.<anonymous> (/Users/leigong/git/friday/lambda/src/functions/hermes/handler.ts:13:20)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .js] (/Users/leigong/git/friday/lambda/node_modules/ts-node/src/index.ts:1587:43)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at /Users/leigong/git/friday/lambda/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:166:133
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async InProcessRunner.run (/Users/leigong/git/friday/lambda/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:166:9)
Here is a simplified version of the code snippet in .ts
import { Browser } from 'puppeteer';
import { addExtra } from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
import chromium from 'chrome-aws-lambda';
const puppeteerExtra = addExtra(chromium.puppeteer as any);
puppeteerExtra.use(StealthPlugin());
browser = await puppeteerExtra.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: chromium.headless,
ignoreHTTPSErrors: true,
})
const page = await browser.newPage();
// other scraping logics
The relevant version of the libraries are below
"puppeteer": "^10.1.0",
"puppeteer-extra": "^3.3.4",
"puppeteer-extra-plugin-adblocker": "^2.13.4",
"puppeteer-extra-plugin-stealth": "^2.11.0",
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 3
- Comments: 19
I worked around this by overriding the version of “clone-deep” in my
package.json+1 Need a fix here
I worked around this by overriding the version of “clone-deep” in my package.json when using yarn berry
I faced another issue while using puppeteer-extra and pnpm.
Cannot find module 'kind-of'Root cause is clone-deep package, like others mentioned (saw this package getting used in the error call stack)@Juaoie 's solution worked for me
pnpm解决方案:在package.json文件中加入下面代码
npm解决方案:在package.json文件中加入下面代码
yarn解决方案也是类似,覆盖clone-deep为最新版本就可以了
hey @AdrKacz, did it manage to figure it out? I’m running into the same issue. Also using puppeteer-core