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

Context connection errors #162

Closed
bernatvadell opened this issue Sep 3, 2024 · 14 comments
Closed

Context connection errors #162

bernatvadell opened this issue Sep 3, 2024 · 14 comments

Comments

@bernatvadell
Copy link

bernatvadell commented Sep 3, 2024

Hi,

I'm trying out the library, and I've found some "random" but fairly frequent errors.

file:///app/node_modules/.pnpm/puppeteer-core-patch@1.0.1/node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:429
                .then(({ executionContextId }) => {
                         ^

TypeError: Cannot destructure property 'executionContextId' of 'undefined' as it is undefined.
    at file:///app/node_modules/.pnpm/puppeteer-core-patch@1.0.1/node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:429:26
    at async Promise.all (index 0)
    at async #createIsolatedWorld (file:///app/node_modules/.pnpm/puppeteer-core-patch@1.0.1/node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:415:9)
    at async Promise.all (index 4)
    at async FrameManager.initialize (file:///app/node_modules/.pnpm/puppeteer-core-patch@1.0.1/node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:170:13)
Page.createIsolatedWorld timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
net::ERR_ABORTED at https://xxxx.yyy
net::ERR_INSUFFICIENT_RESOURCES at https://xxxx.yyy
Navigation timeout of 30000 ms exceeded

any ideas?

@thucvu97
Copy link

thucvu97 commented Sep 4, 2024

hi @bernatvadell What is the code you are using that causes the above error?

@bernatvadell
Copy link
Author

bernatvadell commented Sep 4, 2024

Hi!

This is my code (although errors are generated randomly):

const response = await context.page.goto(instruction.params.url, {
          waitUntil: "load",
        });

produces:
file:///app/node_modules/.pnpm/puppeteer-core-patch@1.0.1/node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:429
                .then(({ executionContextId }) => {
                         ^

TypeError: Cannot destructure property 'executionContextId' of 'undefined' as it is undefined.
    at file:///app/node_modules/.pnpm/puppeteer-core-patch@1.0.1/node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:429:26
    at async Promise.all (index 0)
    at async #createIsolatedWorld (file:///app/node_modules/.pnpm/puppeteer-core-patch@1.0.1/node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:415:9)
    at async Promise.all (index 4)
    at async FrameManager.initialize (file:///app/node_modules/.pnpm/puppeteer-core-patch@1.0.1/node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:170:13)

or

TimeoutError: Navigation timeout of 30000 ms exceeded

This code retrieves elements given a selector and generates a list of elements with the element's metadata. It also causes protocol issues at times.

const elements = instruction.params.selector
          ? (await context.page.$$(instruction.params.selector)) ?? []
          : instruction.params.xpath
          ? (await context.page.$$(instruction.params.xpath)) ?? []
          : [];

        return {
          ok: true,
          result: await Promise.all(
            elements.map(async (node) => {
              const result = await node.evaluateHandle((node) => {
                if (node.nodeType !== Node.ELEMENT_NODE) {
                } else {
                  const element = node as HTMLElement;
                  const attrs: Record<string, string> = {};
                  for (let i = 0; i < element.attributes.length; i++) {
                    const attr = element.attributes.item(i);
                    if (!attr) continue;
                    attrs[attr.name] = attr.value;
                  }
                  return {
                    tagName: element.tagName,
                    attrs,
                    innerText: element.innerText,
                    innerHtml: element.innerHTML,
                  };
                }
              });
              return await result.jsonValue();
            })
          ),
        };

@vootsman
Copy link

vootsman commented Sep 5, 2024

I also started getting the same error (didn't occur with the previous version)

file://...../node_modules/puppeteer-core-patch/lib/esm/puppeteer/cdp/FrameManager.js:429
.then(({ executionContextId }) => {
^

TypeError: Cannot destructure property 'executionContextId' of 'undefined' as it is undefined.

@thucvu97
Copy link

thucvu97 commented Sep 5, 2024

@vootsman
Because the new version has updated the ppt patch, many errors occur. Please share the code where the above error occurs to make it easier to check.

@Zvih
Copy link

Zvih commented Sep 5, 2024

@bernatvadell I've already created issue ticket with it but @zfcsoftware has no plan to fix it, as i understood #133

@mdervisaygan
Copy link
Member

@bernatvadell I've already created issue ticket with it but @zfcsoftware has no plan to fix it, as i understood #133

Hello, currently only headless false is supported. I can update it to pass through Cloudflare with a headless shell, but Cloudflare and other systems will likely fix the issue soon. All libraries, including mine, are being monitored. Even for a simple Captcha click, countless updates had to be made. It's very hard to keep up with these changes. Since this is an open-source project, I can't dedicate a lot of time to it. However, if you're encountering this issue while using headless false and can share the reproduction code, I'd be happy to help as much as I can.

@Zvih
Copy link

Zvih commented Sep 5, 2024

@zfcsoftware I encountered this issue with headless: false, and it's a bit random when you move with goTo to other page. That's why I removed the library from the project for now. However, you did great job.
The other value for the headless parameter (true, new etc.) was mentioned to quickly reproduce the issue

@bernatvadell
Copy link
Author

yes, we are using headless to false

@petar-ps
Copy link

petar-ps commented Sep 5, 2024

I get this error on Docker if try to use defaultViewport or page.setViewport.
On windows everything is fine.

Btw turnstile bypass does not work on Docker but it works on Windows i dont know why.

@bernatvadell
Copy link
Author

I have reviewed a few things that could affect resource consumption:

  • An xvfb session is initialized every time I create a browser instance.
  • The "pageController" function creates as many "disconnected" events as pages are created.

@vootsman
Copy link

vootsman commented Sep 6, 2024

@vootsman Because the new version has updated the ppt patch, many errors occur. Please share the code where the above error occurs to make it easier to check.

I use the connect method to create a page, but I actually do the actual using of the browser by hand, so it sometimes works for hours, other times it crashes sooner (with the above error)

@mdervisaygan
Copy link
Member

Can you try again with the latest version?

@vootsman
Copy link

vootsman commented Sep 7, 2024

Can you try again with the latest version?

I've been using for ~30 minutes with no crashes, so I'll call it success for now

@Zvih
Copy link

Zvih commented Sep 7, 2024

It seems issue gone, at least for now. Great work

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

No branches or pull requests

6 participants