Bug Description
HTTP/2 requests with a body on GET are broken, and the same code path also affects HEAD when a body is provided.
Reproducible By
Run the following in root
import { createServer } from "node:http2";
import { H2CClient } from "./index.js";
const server = createServer((req, res) => {
req.resume();
req.on("end", () => res.end("ok"));
});
server.listen(0, async () => {
const client = new H2CClient(`http://localhost:${server.address().port}/`);
client.request({ path: "/", method: "GET", body: "hello" }, (err) => {
console.error(err);
client.destroy();
server.close();
});
});
Observe that the request fails with ERR_STREAM_WRITE_AFTER_END.
Expected Behavior
A GET or HEAD request with a provided body should not create an already-ended HTTP/2 stream.
Logs & Screenshots
Error [ERR_STREAM_WRITE_AFTER_END]: write after end
at _write (node:internal/streams/writable:487:11)
at Writable.write (node:internal/streams/writable:508:10)
at writeBuffer (/Users/trivikram/workspace/undici/lib/dispatcher/client-h2.js:859:16)
at writeBodyH2 (/Users/trivikram/workspace/undici/lib/dispatcher/client-h2.js:792:7)
at writeH2 (/Users/trivikram/workspace/undici/lib/dispatcher/client-h2.js:675:5)
at Object.write (/Users/trivikram/workspace/undici/lib/dispatcher/client-h2.js:157:14)
at _resume (/Users/trivikram/workspace/undici/lib/dispatcher/client.js:656:50)
at resume (/Users/trivikram/workspace/undici/lib/dispatcher/client.js:574:3)
at Client.<computed> (/Users/trivikram/workspace/undici/lib/dispatcher/client.js:293:31)
at /Users/trivikram/workspace/undici/lib/dispatcher/client.js:518:22 {
code: 'ERR_STREAM_WRITE_AFTER_END'
}
Environment
Node v24.14.1
undici 8.1.0
Additional context
N/A
Bug Description
HTTP/2 requests with a body on
GETare broken, and the same code path also affectsHEADwhen a body is provided.Reproducible By
Run the following in root
Observe that the request fails with
ERR_STREAM_WRITE_AFTER_END.Expected Behavior
A
GETorHEADrequest with a provided body should not create an already-ended HTTP/2 stream.Logs & Screenshots
Environment
Node v24.14.1
undici 8.1.0
Additional context
N/A