sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.27k stars 935 forks source link

Request fails with NGHTTP2_PROTOCOL_ERROR for http2 requests #2301

Closed teammakdi closed 11 months ago

teammakdi commented 1 year ago

Describe the bug

Actual behavior

RequestError: Stream closed with error code NGHTTP2_PROTOCOL_ERROR

Expected behavior

Response with status 200

Code to reproduce

import got from 'got';

async function main() {
    try {
        const response = await got('https://frasix.it/ads.txt', {
            http2: true,
        });
        console.log(response.body);
    } catch (error) {
        console.log(error);
    }
}

main()

Checklist

szmarczak commented 11 months ago

This is reproducible even without http2-wrapper:

import http2 from 'http2';

const session = http2.connect('https://frasix.it');
const request = session.request({ ':path': '/ads.txt', ':authority': 'frasix.it' });

console.log(request.sentHeaders);

request.pipe(process.stdout);
request.once('response', status => console.log(status));
request.once('close', () => session.unref());

also reproducible with curl:

$ curl --http2 https://frasix.it/ads.txt
curl: (92) HTTP/2 stream 1 was not closed cleanly: PROTOCOL_ERROR (err 1)
szmarczak commented 11 months ago

I have created https://github.com/nodejs/node/issues/50660 for you