[错误]: 在非常奇怪的情况下截屏时,协议超时 (Docker + 多个选项卡 + networkidle2)
This is a very weird combination of factors leading to this issue, posting it here more in case it helps to unveil some underlying issue than expecting it to be solved for my use case.
We have a puppeteer service we use for taking screenshots of internal pages. It runs in K8s.
A few months back (And I wish I could give you a better answer for what version of pptr/chrome caused the issue), we started seeing the healthchecks starting to fail a lot more than they used to.
Our healthcheck just attempts to load a PNG loaded in our CDN and screenshot that (more as a test that the browser instance is still alive than anything else).
While trimming it down to a repro case, I discovered that this only happens:
a. In Docker (I couldn't repro it running node directly)
b. When using multiple tabs at once (ie: handling request in parallel to the healthcheck running)
c. When the thing being screenshotted is an image (Couldn't repro it by hitting a regular webpage)
d. Only when using waitUntil: 'networkidle2' on the goTo call.
Created a repo with the full repro case (including dockerfile here: https://GitHub.com/nicofff/puppeteer_repro_weird_hang)
Expectation
Screenshots succeed
Reality
file:///app/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:99
#error = new ProtocolError();
^
ProtocolError: Page.captureScreenshot timed out. Increase the 'protocolTimeout' setting in launch/connect calls for a higher timeout if needed.
at <instance_members_initializer> (file:///app/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:99:14)
at new Callback (file:///app/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:103:16)
at CallbackRegistry.create (file:///app/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:22:26)
at Connection._rawSend (file:///app/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Connection.js:104:26)
at CdpCDPSession.send
内容来源: puppeteer/puppeteer