Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(config): keep a comma inside a PUPPETEER_ARGS flag value

Yudhi Armyndharis9eaf0225e6e4
diff --git a/src/config/configuration.spec.ts b/src/config/configuration.spec.ts
index e62a4801f..9d50dae7b 100644
--- a/src/config/configuration.spec.ts
+++ b/src/config/configuration.spec.ts
@@ -64,6 +64,19 @@ describe('configuration — Puppeteer args delimiter', () => {
expect(configuration().engine.puppeteer.args.slice(0, 2)).toEqual(['--no-sandbox', '--disable-setuid-sandbox']);
});
+ // A comma only separates flags when the next token is a flag: Chromium flag values carry commas
+ // themselves, and splitting inside one turned its tail into a stray positional argument.
+ it('keeps a comma inside a flag value in that flag', () => {
+ process.env.PUPPETEER_ARGS =
+ '--no-sandbox,--disable-features=IsolateOrigins,site-per-process, --window-size=1280,720 --disable-gpu,';
+ expect(configuration().engine.puppeteer.args.slice(0, 4)).toEqual([
+ '--no-sandbox',
+ '--disable-features=IsolateOrigins,site-per-process',
+ '--window-size=1280,720',
+ '--disable-gpu',
+ ]);
+ });
+
it('defaults to the Docker-relevant sandbox flag set when unset', () => {
delete process.env.PUPPETEER_ARGS;
expect(configuration().engine.puppeteer.args).toEqual([
diff --git a/src/config/configuration.ts b/src/config/configuration.ts
index 63fbd8818..393a5026f 100644
--- a/src/config/configuration.ts
+++ b/src/config/configuration.ts
@@ -213,9 +213,12 @@ export default () => ({
// Accept either delimiter: .env/compose use commas, the dashboard Infrastructure form
// persists space-separated. Splitting on both keeps each flag a discrete argv token —
// a single glued token like "--no-sandbox --disable-gpu" silently neuters --no-sandbox.
+ // A comma only splits before the next flag, since flag values carry commas of their own
+ // (--disable-features=A,B, --window-size=1280,720).
args: withPinnedBrowserLocale(
(process.env.PUPPETEER_ARGS || '--no-sandbox,--disable-setuid-sandbox,--disable-dev-shm-usage,--disable-gpu')
- .split(/[\s,]+/)
+ .split(/\s+|,+(?=-)/)
+ .map(arg => arg.replace(/^,+|,+$/g, ''))
.filter(Boolean),
),
// Optional path to a system Chromium/Chrome binary. When unset, whatsapp-web.js