BREAKING!!! Require the user to specify the headless type

This commit is contained in:
Kyle McNally 2024-04-15 11:30:16 -04:00
parent 9f3b102e5e
commit 636fa64bfa
2 changed files with 2 additions and 38 deletions

View File

@ -10,11 +10,12 @@ exports.handler = async (event, context) => {
browser = await puppeteer.launch({ browser = await puppeteer.launch({
args: puppeteer.defaultArgs({ args: puppeteer.defaultArgs({
args: chromium.args, args: chromium.args,
headless: "shell",
}), }),
defaultViewport: chromium.defaultViewport, defaultViewport: chromium.defaultViewport,
dumpio: true, dumpio: true,
executablePath: await chromium.executablePath(), executablePath: await chromium.executablePath(),
headless: chromium.headless, headless: "shell",
ignoreHTTPSErrors: true, ignoreHTTPSErrors: true,
}); });

View File

@ -88,13 +88,6 @@ if (isRunningInAwsLambdaNode20()) {
} }
class Chromium { class Chromium {
/**
* Determines the headless mode that chromium will run at
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
* @values true or "new"
*/
private static headlessMode: true | "shell" = "shell";
/** /**
* If true, the graphics stack and webgl is enabled, * If true, the graphics stack and webgl is enabled,
* If false, webgl will be disabled. * If false, webgl will be disabled.
@ -299,36 +292,6 @@ class Chromium {
return result.shift() as string; return result.shift() as string;
} }
/**
* Returns the headless mode.
* "shell" means the 'old' (legacy, chromium < 112) headless mode.
* `true` means the 'new' headless mode.
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
* @returns true | "shell"
*/
public static get headless() {
return this.headlessMode;
}
/**
* Sets the headless mode.
* "shell" means the 'old' (legacy, chromium < 112) headless mode.
* `true` means the 'new' headless mode.
* https://developer.chrome.com/articles/new-headless/#try-out-the-new-headless
* @default "shell"
*/
public static set setHeadlessMode(value: true | "shell") {
if (
(typeof value === "string" && value !== "shell") ||
(typeof value === "boolean" && value !== true)
) {
throw new Error(
`Headless mode must be either \`true\` or 'shell', you entered '${value}'`
);
}
this.headlessMode = value;
}
/** /**
* Returns whether the graphics stack is enabled or disabled * Returns whether the graphics stack is enabled or disabled
* @returns boolean * @returns boolean