Skip to content

Commit e825794

Browse files
Patch dev pupeeteer crash for MacOS 15 (#4713)
* Patch dev pupeeteer crash for MacOS 15 * simplify fix * update comment * reenable failover
1 parent 92752a2 commit e825794

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

collector/processLink/convert/generic.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,30 @@ async function getPageContent({ link, captureAs = "text", headers = {} }) {
137137
try {
138138
let pageContents = [];
139139
const runtimeSettings = new RuntimeSettings();
140+
141+
/** @type {import('puppeteer').PuppeteerLaunchOptions} */
142+
let launchConfig = { headless: "new" };
143+
144+
/* On MacOS 15.1, the headless=new option causes the browser to crash immediately.
145+
* It is not clear why this is the case, but it is reproducible. Since AnythinglLM
146+
* in production runs in a container, we can disable headless mode to workaround the issue for development purposes.
147+
*
148+
* This may show a popup window when scraping a page in development mode.
149+
* This is expected behavior if seen in development mode on MacOS 15+
150+
*/
151+
if (
152+
process.platform === "darwin" &&
153+
process.env.NODE_ENV === "development"
154+
) {
155+
console.log(
156+
"Darwin Development Mode: Disabling headless mode to prevent Chromium from crashing."
157+
);
158+
launchConfig.headless = "false";
159+
}
160+
140161
const loader = new PuppeteerWebBaseLoader(link, {
141162
launchOptions: {
142-
headless: "new",
163+
headless: launchConfig.headless,
143164
ignoreHTTPSErrors: true,
144165
args: runtimeSettings.get("browserLaunchArgs"),
145166
},

0 commit comments

Comments
 (0)