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] Fontconfig error when running Puppeteer/Chromium on AL2023 Lambda #307

Open
tamsingreen opened this issue Oct 11, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@tamsingreen
Copy link

Environment

  • chromium Version: 127
  • puppeteer / puppeteer-core Version: 23.1.1
  • Node.js Version: 20
  • Lambda Runtime: nodejs20.x/Amazon Linux 2023

Expected Behavior

A screenshot is returned with images and text.

Current Behavior

A screenshot is returned with images but no text.

Relevant logs:

Fontconfig error: Cannot load default config file: No such file: (null)
DevTools listening on ws://127.0.0.1:39249/devtools/browser/bf359b0f-ad04-454b-a3fd-ecd2d00fa4c4

Steps to Reproduce

const chromium = require('chromium');

exports.handler = async (event, context, callback) => {
  const { fonts, fontPath, url } = event;
  let result = null;
  let browser = null;

  try {
    await Promise.all(fonts.map((font) => chromium.font(`${fontPath}/${font}`)));

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

    let page = await browser.newPage();

    page.on('console', (msg) => console.log('>PAGE LOG:', msg.text()));

    await page.goto(url || 'https://example.com');

    const element = await page.$('#main');
    return screenshot = element.screenshot();
  } catch (error) {
    return callback(error);
  } finally {
    if (browser !== null) {
      await browser.close();
    }
  }

  return callback(null, result);
};
@tamsingreen tamsingreen added the bug Something isn't working label Oct 11, 2024
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

1 participant