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] Timed out while waiting for the WS endpoint URL to appear in stdout! #177

Open
hanifydvsa opened this issue Nov 9, 2023 · 17 comments
Labels
bug Something isn't working

Comments

@hanifydvsa
Copy link

hanifydvsa commented Nov 9, 2023

Environment

  • chromium Version: 118.0.0
  • puppeteer-core Version: 21.4.1
  • Node.js Version: 16.x
  • Lambda / GCF Runtime: nodejs16

Expected Behavior

No errors and runs as expected running on AWS Lambda

Current Behavior

We sometimes get this error

#TimeoutError: Timed out after 30000 ms while waiting for the WS endpoint URL to appear in stdout!
at ChromeLauncher.launch (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:149:23)
at async parseHTMLToPDF (/var/task/index.js:66:21)
at async Runtime.exports.handler (/var/task/index.js:128:21)

Steps to Reproduce

Unable to reproduce all the time, it seems to be random, this is the code it errors at, specifically on const browser.

async function parseHTMLToPDF(html) {
    const browser = await puppeteer.launch({
        executablePath: await chromium.executablePath(),
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        headless: chromium.headless,
    });
    const page = await browser.newPage();
    await page.setContent(html);
    const pdf = await page.pdf(pdfParams);
    await browser.close();

    return pdf;
}

Possible Solution

I am thinking whether it might be multiple run times at the same time. I initially had it at 30 seconds timeout for the whole lambda which ran fine on the old chromium method before upgrading to yours following a forced change from nodejs12 which meant we couldn't revert back to it and saw that this is the only repo working so I did the conversion following your npm help. I saw these timeout issues so tried increasing to 3 minutes but to no avail.

This does not seem to occur all the time and anyway of replicating the failure each and every time has not worked for me.

Your input would be greatly appreciated.

@hanifydvsa hanifydvsa added the bug Something isn't working label Nov 9, 2023
@hanifydvsa
Copy link
Author

After updating the memory from 512MB to 1600MB as suggested in the readme.

I now get this:

Message: Invoke Error {"errorType":"TimeoutError","errorMessage":"Timed out after waiting 30000ms","name":"TimeoutError","stack":["TimeoutError: Timed out after waiting 30000ms"," at /opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/common/util.js:510:19"," at /opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:3:59978"," at t.f._next (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:3:11821)"," at t.next (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:3:6459)"," at t.<anonymous> (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:3:71381)"," at t._execute (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:3:28234)"," at t.execute (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:3:28057)"," at t.flush (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/third_party/rxjs/rxjs.js:3:32540)"," at listOnTimeout (node:internal/timers:559:17)"," at processTimers (node:internal/timers:502:7)"]}

@Sparticuz
Copy link
Owner

Can you add dumpio: true to your puppeteer launch call?

@Sparticuz
Copy link
Owner

This might have been fixed by 119.0.2, please check and also add dumpio: true

@hanifydvsa
Copy link
Author

Thanks @Sparticuz I cannot update the plugin yet as we are coming to a change freeze but I've done a dumpio:true just to see if it shows anything the next time it errors.

It seems to occur in clusters and then nothing for a few days, so I am just waiting and seeing what is going on. I shall certainly try your updated plugin asap though.

Many thanks for your support.

@hanifydvsa
Copy link
Author

hanifydvsa commented Dec 20, 2023

Hi @Sparticuz,

I got an error this morning but it wasn't an error that stopped it doing its job unlike before. Not sure if this extra parameter is a catch all or something and it will still continue but this is what was shown:

Fontconfig error: No writable cache directories
DevTools listening on ws://127.0.0.1:45059/devtools/browser/22b6cc8a-e014-4540-b754-e125d8ac8ae6
[1220/084403.873041:ERROR:command_buffer_proxy_impl.cc(319)] GPU state invalid after WaitForGetOffsetInRange.
With the GPU state invalid the one flagging as the actual error which I get emailed every time one occurs.

Another one just showed up, all seemed to convert fine but an error of:

[1220/102113.694826:ERROR:command_buffer_proxy_impl.cc(127)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.

@hanifydvsa
Copy link
Author

hanifydvsa commented Jan 15, 2024

Hi @Sparticuz

I found a html that is created that always fails, the main issue is that it includes personal information so I can't include it here, I did do a print to pdf successfully on chrome and did notice it is 99 pages, also tried to change the timeout but it seems set to 30seconds regardless, which may be part of the reason? Not sure how I can proceed with that but I did update it to the latest version:

node_modules/@sparticuz/chromium": {
"version": "119.0.2",

"node_modules/puppeteer-core": {
"version": "21.7.0",

But I still get the following and for this, it occurs every single time it is ran:

Message: Invoke Error 	
{
    "errorType": "TimeoutError",
    "errorMessage": "Timed out after 30000 ms while waiting for the WS endpoint URL to appear in stdout!",
    "name": "TimeoutError",
    "stack": [
        "TimeoutError: Timed out after 30000 ms while waiting for the WS endpoint URL to appear in stdout!",
        "    at ChromeLauncher.launch (/opt/nodejs/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:139:23)",
        "    at async parseHTMLToPDF (/var/task/index.js:66:21)",
        "    at async Runtime.exports.handler (/var/task/index.js:128:21)"
    ]
}

@hanifydvsa
Copy link
Author

hanifydvsa commented Jan 15, 2024

Just to add to above @Sparticuz it seems to be 100% related to pages, I reduced it from 99 (in chrome) to 50 (in chrome) or 61 in your plugin and it worked fine

Made a quick file which has no personal information on it and hopefully you can replicate

made-up-data.zip

@hanifydvsa
Copy link
Author

hanifydvsa commented Jan 16, 2024

Sorry @Sparticuz found the issue and all it was, was lack of memory for the lambda. 30 seconds seems hard set no matter what I did but increasing the memory allocated (not just ephemeral storage) I guess ensured it could do it in less than 30 seconds

@hanifydvsa
Copy link
Author

Apologies, seem I may have closed this prematurely. I still get these even after the upgrade:

  1. [0219/141842.515807:ERROR:command_buffer_proxy_impl.cc(127)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.

  2. [0216/111644.245246:ERROR:shared_image_manager.cc(220)] SharedImageManager::ProduceSkia: Trying to Produce a Skia representation from a non-existent mailbox.

  3. [0216/121933.465824:ERROR:command_buffer_proxy_impl.cc(319)] GPU state invalid after WaitForGetOffsetInRange.

@hanifydvsa hanifydvsa reopened this Feb 19, 2024
@hanifydvsa
Copy link
Author

Hi @Sparticuz any suggestions on the above errors? Many thanks.

@Sparticuz
Copy link
Owner

Nothing specific, just try increasing memory.

@Sparticuz
Copy link
Owner

Sorry missed the last comment, those are chromium errors, take a look at your launch arguments.

@hanifydvsa
Copy link
Author

thanks @Sparticuz

    const browser = await puppeteer.launch({
        executablePath: await chromium.executablePath(),
        args: chromium.args,
        defaultViewport: chromium.defaultViewport,
        headless: chromium.headless,
        dumpio: true
    });

I cant see what else i can change though

@hanifydvsa
Copy link
Author

@Sparticuz sorry to ping, any suggestions you can offer would be greatly appreciated as I cannot recreate this issue consistently

@onhate
Copy link

onhate commented Jul 23, 2024

Just to add more information, after adding dumpio: true I've seen I had to increase the /tmp ephemeral storage of my lambda.

@hanifydvsa
Copy link
Author

hanifydvsa commented Jul 24, 2024

Just to add more information, after adding dumpio: true I've seen I had to increase the /tmp ephemeral storage of my lambda.

Thanks though I thought I had it already quite high but i've changed from 3000MB to 5000MB, i would have thought this would be enough?

Description
Lambda function to convert html to pdf.
Memory
2560MB
Ephemeral storage
5000MB

@deathemperor
Copy link

[0802/102300.449785:ERROR:command_buffer_proxy_impl.cc(132)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer. happens intermittently for me too

launch arguments:

[
  '--allow-pre-commit-input',
  '--disable-background-networking',
  '--disable-background-timer-throttling',
  '--disable-backgrounding-occluded-windows',
  '--disable-breakpad',
  '--disable-client-side-phishing-detection',
  '--disable-component-extensions-with-background-pages',
  '--disable-component-update',
  '--disable-default-apps',
  '--disable-dev-shm-usage',
  '--disable-extensions',
  '--disable-hang-monitor',
  '--disable-ipc-flooding-protection',
  '--disable-popup-blocking',
  '--disable-prompt-on-repost',
  '--disable-renderer-backgrounding',
  '--disable-sync',
  '--enable-automation',
  '--enable-blink-features=IdleDetection',
  '--export-tagged-pdf',
  '--force-color-profile=srgb',
  '--metrics-recording-only',
  '--no-first-run',
  '--password-store=basic',
  '--use-mock-keychain',
  '--disable-domain-reliability',
  '--disable-print-preview',
  '--disable-speech-api',
  '--disk-cache-size=33554432',
  '--mute-audio',
  '--no-default-browser-check',
  '--no-pings',
  '--single-process',
  '--font-render-hinting=none',
  '--disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints,AudioServiceOutOfProcess,IsolateOrigins,site-per-process',
  '--enable-features=NetworkServiceInProcess2,SharedArrayBuffer',
  '--hide-scrollbars',
  '--ignore-gpu-blocklist',
  '--in-process-gpu',
  '--window-size=1920,1080',
  '--use-gl=angle',
  '--use-angle=swiftshader',
  '--allow-running-insecure-content',
  '--disable-setuid-sandbox',
  '--disable-site-isolation-trials',
  '--disable-web-security',
  '--no-sandbox',
  '--no-zygote',
  "--headless='shell'",
  '--disable-gpu',
  '--disable-lcd-text',
  '--font-render-hinting=none'
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants