From 94029e6252fe8c8f78480fb90811fd2a24fd52e2 Mon Sep 17 00:00:00 2001 From: AB498 Date: Sun, 30 Mar 2025 13:24:43 +0600 Subject: [PATCH] puppeteer server: deduplication of launch option args --- src/puppeteer/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/puppeteer/index.ts b/src/puppeteer/index.ts index 1bee5220..1849c783 100644 --- a/src/puppeteer/index.ts +++ b/src/puppeteer/index.ts @@ -186,7 +186,13 @@ function deepMerge(target: any, source: any): any { const targetVal = target[key]; const sourceVal = source[key]; if (Array.isArray(targetVal) && Array.isArray(sourceVal)) { - output[key] = [...targetVal, ...sourceVal]; + // Deduplicate args/ignoreDefaultArgs, prefer source values + output[key] = [...new Set([ + ...(key === 'args' || key === 'ignoreDefaultArgs' ? + targetVal.filter((arg: string) => !sourceVal.some((launchArg: string) => arg.startsWith('--') && launchArg.startsWith(arg.split('=')[0]))) : + targetVal), + ...sourceVal + ])]; } else if (sourceVal instanceof Object && key in target) { output[key] = deepMerge(targetVal, sourceVal); } else {