takeScreenshot hangs on missing assets
good-idea opened this issue · comments
I was having an issue where my test suddenly started timing out -- I finally debugged it by launching chromium with generateImage({ launch: { ... } })
. I noticed in the network tab that the request for a font file was pending, and would never resolve (either with the resource or as a 404).
This was solved by adding my asset directory to the options (serve: ['public']
). But, it was quite difficult to figure out that this was the issue. Ideally, puppeteer would just treat it as a normal 404 and not load the asset -- then I would see in my screenshots that my fonts aren't loading.
I see that opts.waitUntilNetworkIdle
is false
by default.. So I'm not sure why puppeteer was stuck on this asset. I've tried goofing around in createServer
to handle this but I didn't have much luck.
Thanks for sharing your findings. I vaguely remember dealing with waitUntilNetworkIdle
to ensure the page is completely loaded before taking the screenshot. Otherwise you could get discrepancies more often due to network instability.
I don't recall whether I ended up making it part of the defaults or not as it's been quite a while since I worked on this 😅