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
  • PDF

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

Most upvoted comments

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:

import puppeteer from 'puppeteer';
const ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36';
const url = "https://www.adobe.com/it/creativecloud/photography/basics/light.html";

const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
page.setUserAgent(ua);

const res = await page.goto(url)
const text = await res.text();
console.log(text);

The issue is reproducible, but looks like Adobe has a way to prevent automation, so closing as won’t fix.

It also affects other pages. Unfortunately, specifying a user agend is no longer sufficient. Are there any ideas on how to circumvent this procedure?

using the user agent fixed for me

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.

import puppeteer from 'puppeteer-extra'; 
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
import AdblockerPlugin from 'puppeteer-extra-plugin-adblocker';

puppeteer.use(StealthPlugin());
puppeteer.use(AdblockerPlugin({ blockTrackers: true }))

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: false flag works for now. however i didn’t find any way to do this headlessly. it also seems related to Akamai.