puppeteer: [Bug]: net::ERR_HTTP2_PROTOCOL_ERROR when accessing a http/3 page
Minimal, reproducible example
import puppeteer from "puppeteer";
var browser = await puppeteer.launch({
headless:"new" // no error in headful mode
});
let url = "https://www.adobe.com/it/creativecloud/photography/basics/light.html";
const page = await browser.newPage();
await page.goto(url, {waitUntil: "domcontentloaded", timeout: 40000});
let data = await page.$eval("h1",(element)=>{
return element.innerText;
});
console.log(data)
console.log("done")
Error string
net::ERR_HTTP2_PROTOCOL_ERROR
Bug behavior
- Flaky
Background
I’ve tested the code on Mac and aws lambda. Same error. It works fine if using headless:false. Error occurs in multiple node versions: 20.10.0, also on 18.14.1 and 16.15.0
Expectation
I am expecting code to visit the page and not crash. The culprit may be that adobe is using http/3. I was not able to confirm it, because other http/3 websites do work ( e.g. https://blog.cloudflare.com/http3-the-past-present-and-future)
Reality
I get an error:
file:///pathtoproject/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Frame.js:167
? new Error(${response.errorText} at ${url})
^
Error: net::ERR_HTTP2_PROTOCOL_ERROR at https://www.adobe.com/it/creativecloud/photography/basics/light.html at navigate (file:///pathtoproject/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Frame.js:167:27) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Deferred.race (file:///pathtoproject/node_modules/puppeteer-core/lib/esm/puppeteer/util/Deferred.js:80:20) at async CdpFrame.goto (file:///pathtoproject/node_modules/puppeteer-core/lib/esm/puppeteer/cdp/Frame.js:133:25) at async CdpPage.goto (file:///pathtoproject/node_modules/puppeteer-core/lib/esm/puppeteer/api/Page.js:565:20) at async file:///pathtoproject/index.js:9:1
Puppeteer configuration file (if used)
No response
Puppeteer version
21.7.0
Node version
20.10.0
Package manager
npm
Package manager version
8.5.5
Operating system
macOS
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20
For anyone coming to this issue, what fixed this for me was providing a user agent to puppeteer; the default user agent resulted in the error, while providing one was enough for the web server to properly respond, ex:
It also affects other pages. Unfortunately, specifying a user agend is no longer sufficient. Are there any ideas on how to circumvent this procedure?
Interesting, no combination of User Agent or any other “tricks” would work for me. It really must depend on the site in question
Then I discovered puppeteer-extra.
After this, everything worked.
What seems to have worked is after the error is thrown, try the page2.goto() again. The success rate is now close to 100%.
Update: using the
headless: falseflag works for now. however i didn’t find any way to do this headlessly. it also seems related to Akamai.