All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
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.
17 lines
508 B
JavaScript
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],
|
|
};
|
|
}
|