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] Failed to launch the browser process! /tmp/chromium: /tmp/chromium: cannot execute binary file #235

Closed
alexey2baranov opened this issue Mar 4, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@alexey2baranov
Copy link

alexey2baranov commented Mar 4, 2024

Environment

  • chromium Version: ^121.0.0
  • puppeteer / puppeteer-core Version: ^21.11.0
  • Node.js Version: 16.x
  • Lambda / GCF Runtime: nodejs16
  • Serverless: ^3.27.0
  • serverless-layers: ^2.6.1

Expected Behavior

Run chrome, load html page and store as PDF

Current Behavior

Get an error "Failed to launch the browser process!
/tmp/chromium: /tmp/chromium: cannot execute binary file
TROUBLESHOOTING: https://pptr.dev/troubleshooting" when running 'puppeteer.launch()'

Steps to Reproduce

const chromium = require('chromium');
import { dirname } from 'path';
import { readdirSync } from 'fs';


exports.handler = async (event, context, callback) => {
  let result = null;
  let browser = null;

  try {
      // log tmp folder content to be sure that chromium was correctly extracted
 
      const executablePath = await chromium.executablePath();
      const executableDir = dirname(executablePath);

      console.info({
        executablePath,
        executableDir,
        executableDirContent: readdirSync(executableDir),
      });

    // console output: 
    // {"executablePath":"/tmp/chromium","executableDir":"/tmp","executableDirContent":["al2","chromium","fonts","libEGL.so","libGLESv2.so","libvk_swiftshader.so","libvulkan.so.1","vk_swiftshader_icd.json"]}

    browser = await puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
      executablePath: executablePath,
      headless: chromium.headless,
      ignoreHTTPSErrors: true,
    });
  } catch (error) {
    return callback(error);
  } finally {
    if (browser !== null) {
      await browser.close();
    }
  }

  return callback(null, result);
};

Possible Solution

I don't have a solution, I just can say what I have already done to narrow down the search.

First I've run my test locally and during the local test I was able to receive pdf file.

Also I've checked that /tmp folder contains all neccesary executables, so seems they was unarchived are present in /tmp folder (see logs above)

Also it's worth notice that we use serverless + serverless-layer plugin. But 99% it doesn't affects this issue as I performed necessary checks. First I checked that the layer contains @Sparticuz/chromium, secondly it was imported from the layer, and thirdly the files were successfully unzipped into /tmp during the first call to executablePath() (see logs above).

@alexey2baranov alexey2baranov added the bug Something isn't working label Mar 4, 2024
@Sparticuz
Copy link
Owner

Are you using graviton instances?

@alexey2baranov
Copy link
Author

yes we do

@Sparticuz
Copy link
Owner

At the moment, this package only supports x86 instances, See #186

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

2 participants