chore: use env variable to switch browser headless mode

This commit is contained in:
yanlong.wang 2025-03-13 16:00:55 +08:00
parent adce02d708
commit ff7612414c
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37
2 changed files with 22 additions and 1 deletions

21
.vscode/launch.json vendored
View File

@ -39,6 +39,27 @@
"preLaunchTask": "Backend:build:watch",
"killBehavior": "forceful"
},
{
"name": "Debug Stand Alone Crawl + Browser",
"request": "launch",
"runtimeArgs": [
"--env-file=.secret.local",
],
"env": {
"GCLOUD_PROJECT": "reader-6b7dc",
"DEBUG_BROWSER": "true",
"LD_PRELOAD": "/usr/local/lib/libcurl-impersonate-chrome.dylib"
},
"cwd": "${workspaceFolder}",
"program": "build/stand-alone/crawl.js",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
"outputCapture": "std",
"preLaunchTask": "Backend:build:watch",
"killBehavior": "forceful"
},
{
"name": "Debug Stand Alone Search",
"request": "launch",

View File

@ -561,7 +561,7 @@ export class PuppeteerControl extends AsyncService {
}
this.browser = await puppeteer.launch({
timeout: 10_000,
headless: true,
headless: !Boolean(process.env.DEBUG_BROWSER),
executablePath: process.env.OVERRIDE_CHROME_EXECUTABLE_PATH,
args: ['--disable-dev-shm-usage']
}).catch((err: any) => {