Bug Description
We upgraded to undici v8 which changed allowH2 to default to true. Some third-party APIs we integrate with require a body on DELETE requests (batch deletions). This started crashing with an uncaught AssertionError. Worked fine before v8 over HTTP/1.1.
writeH2 in client-h2.js nulls contentLength for methods that aren't POST/PUT/PATCH (!expectsPayload), but the body (converted to Buffer in the Request constructor) is still passed to writeBuffer, which asserts contentLength === body.byteLength (null === N).
Happy to open a PR with a fix.
Reproducible By
import { request } from 'undici';
await request('https://www.google.com', {
method: 'DELETE',
body: JSON.stringify({ ids: [1] }),
});
Expected Behavior
The request should be sent without an assertion error, as it does over HTTP/1.1.
Logs & Screenshots
AssertionError [ERR_ASSERTION]: buffer body must have content length
at writeBuffer (undici/lib/dispatcher/client-h2.js:857:7)
at writeBodyH2 (undici/lib/dispatcher/client-h2.js:792:7)
at writeH2 (undici/lib/dispatcher/client-h2.js:675:5)
Environment
- undici 8.1.0
- Node.js v24.14.0
- Linux
Bug Description
We upgraded to undici v8 which changed
allowH2to default totrue. Some third-party APIs we integrate with require a body on DELETE requests (batch deletions). This started crashing with an uncaughtAssertionError. Worked fine before v8 over HTTP/1.1.writeH2inclient-h2.jsnullscontentLengthfor methods that aren't POST/PUT/PATCH (!expectsPayload), but the body (converted to Buffer in the Request constructor) is still passed towriteBuffer, which assertscontentLength === body.byteLength(null === N).Happy to open a PR with a fix.
Reproducible By
Expected Behavior
The request should be sent without an assertion error, as it does over HTTP/1.1.
Logs & Screenshots
Environment