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

[Bug] RangeError: Maximum call stack size exceeded because of hacks to Function.prototype.toString in puppeteer-extra-plugin-stealth #890

Open
nomagick opened this issue May 13, 2024 · 0 comments
Labels
issue: bug report A bug has been reported needs triage

Comments

@nomagick
Copy link

Describe the bug
With puppeteer-extra-plugin-stealth plugin applied,
open any page in the internet archive, for example https://web.archive.org/web/20240513040624/https://www.google.com/
Then go to the terminal, you will see
RangeError: Maximum call stack size exceeded triggered for .toString() calls to any function.

I've looked into the code a bit and found the plugin making a lot of hacks to Function.prototype in some util function and the util function is used in many other places.

It might be the way-back-machine also hacking the browser environment a bit and some how it created a loop.

TBH I didn't quite get the purpose of the hacking and why it's always applied globally to Function.prototype.

But it might be time to consider refactoring this hack to use some constant WeakMap instead of chaining functions.

Code Snippet

const puppeteer = require('puppeteer-extra')
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin())

;(async () => {
  const browser = await puppeteer.launch({headless: false})
  const page = await browser.newPage()
  await page.goto('https://web.archive.org/web/20240513040624/https://www.google.com/')
  // ...
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug report A bug has been reported needs triage
Projects
None yet
Development

No branches or pull requests

1 participant