farmcontrol-api/src/puppeteerLaunchOptions.js
Tom Butcher 0b94774443
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
Refactor Puppeteer launch options for improved configurability
This update introduces a new module, `puppeteerLaunchOptions.js`, which centralizes the Puppeteer launch configuration. The `getPuppeteerLaunchOptions` function is added to provide customizable launch arguments, enhancing the flexibility of browser instantiation in both `mailworker.js` and `pdffactory.js`. This refactor improves code maintainability and allows for easier adjustments to Puppeteer settings in the future.
2026-08-19 22:19:05 +01:00

17 lines
508 B
JavaScript

import puppeteer from 'puppeteer';
const BASE_ARGS = ['--no-sandbox', '--disable-setuid-sandbox'];
/**
* Puppeteer launch options using the Chrome downloaded to the Puppeteer cache
* (e.g. /home/farmcontrol/.cache/puppeteer on Linux), not a system-installed browser.
*/
export function getPuppeteerLaunchOptions(extraArgs = []) {
return {
executablePath:
process.env.PUPPETEER_EXECUTABLE_PATH || puppeteer.executablePath(),
headless: true,
args: [...BASE_ARGS, ...extraArgs],
};
}