Puppeteer
Learn how to configure Puppeteer on Discloud, including dependencies and RAM adjustments, to ensure proper operation in container environments.
📌 Requirements
To use Puppeteer on Discloud, a minimum of 512 MB RAM is recommended for basic tasks. However, depending on the complexity of your application, more RAM may be required.
If Puppeteer does not function correctly (e.g., no QR code in logs, crashes), increase the allocated RAM!
📦 Adding Puppeteer
Puppeteer requires additional system dependencies. You must add puppeteer
to the APT
field in your discloud.config
file.
APT=tools, puppeteer
# ...
⚙️ Configuring Puppeteer
Since Puppeteer runs in a containerized environment, you must add the --no-sandbox
argument to ensure it works correctly.
const puppeteer = require("puppeteer");
(async () => {
const browser = await puppeteer.launch({
args: ["--no-sandbox"]
});
const page = await browser.newPage();
await page.goto("https://example.com");
console.log(await page.title());
await browser.close();
})();
🚨 Why --no-sandbox
?
--no-sandbox
?Running Puppeteer inside a container requires disabling the sandbox to prevent security restrictions from blocking execution.
⚙️ Using Puppeteer with whatsapp-web.js
whatsapp-web.js
Since whatsapp-web.js
also uses Puppeteer for QR code generation and background interactions, you must include --no-sandbox
in its configuration.
const { Client } = require("whatsapp-web.js");
const client = new Client({
puppeteer: {
args: ["--no-sandbox"],
}
});
client.initialize();
Last updated