feat: add chromium sandbox skipping (#209)

This commit is contained in:
Andrew Mackrodt
2020-09-23 13:35:56 +01:00
committed by GitHub
parent 6608a79769
commit 20656805c1
4 changed files with 13 additions and 0 deletions
+1
View File
@@ -5,6 +5,7 @@ config({path: path.resolve(__dirname, '../.env')});
const browser = {
isHeadless: process.env.HEADLESS ? process.env.HEADLESS === 'true' : true,
isTrusted: process.env.BROWSER_TRUSTED ? process.env.BROWSER_TRUSTED === 'true' : false,
maxSleep: Number(process.env.PAGE_SLEEP_MAX ?? 10000),
minSleep: Number(process.env.PAGE_SLEEP_MIN ?? 5000),
open: process.env.OPEN_BROWSER === 'true'
+10
View File
@@ -14,7 +14,17 @@ puppeteer.use(adBlocker);
* Starts the bot.
*/
async function main() {
const args: string[] = [];
// Skip Chromium Linux Sandbox
// https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#setting-up-chrome-linux-sandbox
if (Config.browser.isTrusted) {
args.push('--no-sandbox');
args.push('--disable-setuid-sandbox');
}
const browser = await puppeteer.launch({
args,
defaultViewport: {
height: Config.page.height,
width: Config.page.width