Non-GET http2 requests without a body hang indefninitely #2589
Closed
Description
opened on Jan 4, 2024
Bug Description
When using fetch to make non-GET/HEAD http2 requests, the function call hangs indefinitely. Passing in an empty string in place of the body fixes this issue.
Reproducible By
The following js script triggers the issue on undici v6.2.1
'use strict'
const { fetch, Client } = require('undici')
async function main () {
const client = new Client("https://google.com", { allowH2: true });
const res = await fetch("https://google.com", {
dispatcher: client,
baseURL: 'https://google.com',
url: 'https://google.com/',
method: "POST",
})
const data = await res.text()
console.log('response received', res.status)
console.log('headers', res.headers)
console.log('data', data)
}
main()
Expected Behavior
The function call should send the request with an empty body.
Environment
macOS 14.0, node v20.8.1, undici v6.2.1
Additional context
I believe the issue is closely related to #2258 , but while this PR had only fixed GET/HEAD requests, this actually affects all kinds of requests.
Activity