From d4c4ca2a615fd8254d7fc3b25fe83f8c3c93570e Mon Sep 17 00:00:00 2001 From: Andy Holman Date: Mon, 29 Jun 2026 13:21:29 -0400 Subject: [PATCH] Add protocolTimeout support to puppeteer launch options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Batch print jobs with large case counts can exceed Puppeteer's default 180 second CDP protocol timeout, resulting in ProtocolError: Network.enable timed out. Puppeteer exposes protocolTimeout in its launch options to raise this limit, but Grover never extracted it into launchParams — the value would silently pass through to page.pdf() where it has no effect. This change extracts it so callers can configure the CDP timeout when longer-running operations require it. Also adds protocol_timeout to the integer coercion list in OptionsFixer so it works consistently when set via HTML meta tags, which always produce string values. See: https://github.com/Studiosity/grover/issues/248 --- lib/grover/js/processor.cjs | 6 ++++++ lib/grover/options_fixer.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/grover/js/processor.cjs b/lib/grover/js/processor.cjs index d549e57..8806021 100644 --- a/lib/grover/js/processor.cjs +++ b/lib/grover/js/processor.cjs @@ -110,6 +110,12 @@ const _processPage = (async (convertAction, uriOrHtml, options) => { launchParams.timeout = launchTimeout; } + // Set protocol timeout if given (controls CDP message round-trip timeout) + const protocolTimeout = options.protocolTimeout; delete options.protocolTimeout; + if (protocolTimeout !== undefined) { + launchParams.protocolTimeout = protocolTimeout; + } + // Launch the browser and create a page browser = await puppeteer.launch(launchParams); } diff --git a/lib/grover/options_fixer.rb b/lib/grover/options_fixer.rb index 4e66a1e..0f8b7c3 100644 --- a/lib/grover/options_fixer.rb +++ b/lib/grover/options_fixer.rb @@ -46,7 +46,7 @@ def fix_boolean_options! def fix_integer_options! fix_options!( 'viewport.height', 'viewport.width', - 'timeout', 'launch_timeout', 'request_timeout', 'convert_timeout', 'wait_for_timeout', + 'timeout', 'launch_timeout', 'protocol_timeout', 'request_timeout', 'convert_timeout', 'wait_for_timeout', &:to_i ) end