Skip to content

Non-GET http2 requests without a body hang indefninitely #2589

Closed
@ktaekwon000

Description

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions