Bug Description
Using Node.js 26 with Undici v8's fetch alongside a Undici v7 Agent dispatcher causes responses to drop their headers, including content-type / content-encoding, which would cause the body to not be decompressed for example
Reproducible By
import { createServer } from "node:http";
import { brotliCompressSync } from "node:zlib";
import { Agent } from "undici";
const body = Buffer.from('body content');
const compressedBody = brotliCompressSync(body);
const server = createServer((_request, response) => {
response.writeHead(200, {
"content-type": "application/x-ndjson",
"content-encoding": "br",
"another-test-header": "test-value",
});
response.end(compressedBody);
});
await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
const { port } = server.address();
const url = `http://127.0.0.1:${port}/`;
const agent = new Agent();
async function run(label, init) {
const response = await fetch(url, init);
const body = Buffer.from(await response.arrayBuffer());
console.log('---', label, '---');
console.log('Response headers', response.headers);
console.log('Body', body.toString());
}
console.log('Using Node.js', process.version, 'with bundled fetch Undici', process.versions.undici);
await run("No dispatcher", {});
await run("Undici v7 dispatcher", { dispatcher: agent });
server.close();
Running using Node.js 24, both versions with or without using Undici v7 dispatcher work as expected:
proto run node 24.16.0 -- repro.js
Running using Node.js 26, not using the Undici v7 dispatcher works but using it causes the response to loose its headers and the body to not be decompressed:
proto run node 26.3.0 -- repro.js
Expected Behavior
Using a Undici v7 Agent with Undici v8's fetch should either not drop the response headers (like when using Undici v7's fetch), or explicitely error at runtime before making a request if that combinaison is not supported. This can happen easily for applications or libraries installing Undici v7 explicitly (since Node.js' bundled Undici doesn't explicitly expose the Agent class) while routinely upgrading the app from Node.js 24 to 26
Logs & Screenshots
Shared above
Environment
Any Node.js 26 environment with Undici v7 installed
Additional context
I found this while investigating an upstream issue: vercel/sandbox#198
Bug Description
Using Node.js 26 with Undici v8's
fetchalongside a Undici v7Agentdispatcher causes responses to drop their headers, includingcontent-type/content-encoding, which would cause the body to not be decompressed for exampleReproducible By
Running using Node.js 24, both versions with or without using Undici v7 dispatcher work as expected:
Running using Node.js 26, not using the Undici v7 dispatcher works but using it causes the response to loose its headers and the body to not be decompressed:
Expected Behavior
Using a Undici v7
Agentwith Undici v8'sfetchshould either not drop the response headers (like when using Undici v7'sfetch), or explicitely error at runtime before making a request if that combinaison is not supported. This can happen easily for applications or libraries installing Undici v7 explicitly (since Node.js' bundled Undici doesn't explicitly expose theAgentclass) while routinely upgrading the app from Node.js 24 to 26Logs & Screenshots
Shared above
Environment
Any Node.js 26 environment with Undici v7 installed
Additional context
I found this while investigating an upstream issue: vercel/sandbox#198