Skip to content

Fix Runtime.callFunctionOn timeout for large files#31

Open
reun100e wants to merge 1 commit into
rkwyu:mainfrom
reun100e:fix-protocol-timeout
Open

Fix Runtime.callFunctionOn timeout for large files#31
reun100e wants to merge 1 commit into
rkwyu:mainfrom
reun100e:fix-protocol-timeout

Conversation

@reun100e
Copy link
Copy Markdown
Contributor

@reun100e reun100e commented Apr 9, 2026

Bug Fix: Runtime.callFunctionOn timeouts on large documents

Description
When downloading large or complex documents with many pages, the npm start command fails with the following error:
ProtocolError: Runtime.callFunctionOn timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.

Cause
Newer versions of Puppeteer enforce a default timeout for the Chrome DevTools Protocol (protocolTimeout), usually set to 180 seconds. In ScribdDownloader.js, the page.evaluate step slowly scrolls to the bottom to lazy-load the entire document. For large books, this process takes significantly longer than the default timeout, causing it to crash before the render is finished.

Solution
This PR updates the puppeteer.launch options inside src/utils/request/PuppeteerSg.js to explicitly set protocolTimeout: 0. This instructs the engine to wait indefinitely for the evaluation script to finish running, which natively matches the timeout: 0 setting that is already present for page navigation.

Testing
Tested locally with a large ~350 page textbook limit and successfully generated and merged the PDF without timeout interruptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant