undici is the HTTP client behind Node.js’s built-in fetch(), and many teams also use the npm package directly for its connection pools, interceptors and lower-level request() API. Version 8.14.0, released on 27 November 2026, is a small release with three changes that matter in real services: the deduplicate interceptor no longer merges requests that carry a body, the decompress interceptor gets a preserveHeaders option, and the retry handler gets a resume option to disable mid-body resumption.
This guide explains each change with runnable code. Every example below was run against [email protected] on Node.js 24, and the outputs shown are real. Source: the v8.14.0 release notes.
Install
undici 8.14.0 declares node >=22.19.0 in its engines field.
npm install [email protected]
Note that the fetch() built into Node.js uses the undici version bundled with your Node release. Installing the npm package only affects code that imports from 'undici'.
Fix: deduplicate no longer mixes up requests with bodies
The deduplicate interceptor sends only one request when several identical requests are in flight at the same time, and shares the response with every caller. Its key is built from the origin, method, path and headers, but not the body.
undici allows a body on GET, and some APIs (Elasticsearch’s _search is the classic example) rely on that. Before 8.14.0, two concurrent GET /_search requests with different bodies were merged: the server saw only the first body, and the second caller received the first caller’s results. In a service that shares one dispatcher across users, that means one user can see another user’s data. PR #6240 fixes it by skipping deduplication for any request that carries a body.
Here is a self-contained demo:
// dedupe.mjs
import { createServer } from 'node:http'
import { Agent, interceptors, request } from 'undici'
let hits = 0
const server = createServer((req, res) => {
hits++
let data = ''
req.on('data', c => (data += c))
req.on('end', () => setTimeout(() => res.end(`results for ${data || 'no body'}`), 50))
})
await new Promise(r => server.listen(0, r))
const origin = `http://localhost:${server.address().port}`
const dedupe = new Agent().compose(interceptors.deduplicate())
const [a, b] = await Promise.all([
request(`${origin}/_search`, { method: 'GET', body: '{"tenant":"alice"}', dispatcher: dedupe }),
request(`${origin}/_search`, { method: 'GET', body: '{"tenant":"bob"}', dispatcher: dedupe })
])
console.log(await a.body.text(), '|', await b.body.text(), '| server hits:', hits)
hits = 0
const [c, d] = await Promise.all([
request(`${origin}/items`, { dispatcher: dedupe }),
request(`${origin}/items`, { dispatcher: dedupe })
])
await c.body.text(); await d.body.text()
console.log('body-less GETs, server hits:', hits)
server.close()
await dedupe.close()
Output on 8.14.0:
results for {"tenant":"alice"} | results for {"tenant":"bob"} | server hits: 2
body-less GETs, server hits: 1
Requests with bodies now each reach the server, while identical body-less GETs are still merged into one.
What to do
If you use interceptors.deduplicate() anywhere that GET requests may carry bodies, upgrade now and treat it as a data-isolation fix. If you can’t upgrade immediately, use the existing skipHeaderNames option to bypass deduplication for those requests (for example, a header your search client always sends), or remove the interceptor from that dispatcher.
New: decompress with preserveHeaders
The decompress interceptor decodes gzip, x-gzip, br, deflate and zstd response bodies. By default it removes Content-Encoding and Content-Length from the response headers, because they describe the compressed body, not the decoded one you receive.
Some code needs the original headers. PR #6239 was written so jsdom can implement XMLHttpRequest, whose response headers describe the encoded response even though the body is decoded. The new preserveHeaders: true option keeps both headers (also in controller.rawHeaders) while still decompressing the body:
// decompress.mjs
import { createServer } from 'node:http'
import { gzipSync } from 'node:zlib'
import { Agent, interceptors, request } from 'undici'
const server = createServer((req, res) => {
const body = gzipSync('hello from a gzipped response')
res.writeHead(200, { 'content-encoding': 'gzip', 'content-length': body.length })
res.end(body)
})
await new Promise(r => server.listen(0, r))
const url = `http://localhost:${server.address().port}/`
for (const preserveHeaders of [false, true]) {
const agent = new Agent().compose(interceptors.decompress({ preserveHeaders }))
const res = await request(url, { dispatcher: agent })
console.log({
preserveHeaders,
encoding: res.headers['content-encoding'],
length: res.headers['content-length'],
body: await res.body.text()
})
}
server.close()
Output (each object condensed onto one line):
{ preserveHeaders: false, encoding: undefined, length: undefined, body: 'hello from a gzipped response' }
{ preserveHeaders: true, encoding: 'gzip', length: '49', body: 'hello from a gzipped response' }
Remember that with preserveHeaders: true, Content-Length is the compressed size (49 bytes here), not the length of the text you read. Don’t use it to pre-allocate buffers for the decoded body. The default stays false, so existing code is unaffected.
New: retry without mid-body resumption
The retry interceptor (and RetryHandler) retries failed requests. If a response fails after its headers were received, it tries to resume the body with a Range request. That is great for downloads, but wrong for a reverse proxy that has already started streaming the response to its own client: resuming would splice two responses together.
PR #6096 adds resume to the retry options. It defaults to true (the old behaviour). With resume: false, an error after the headers is passed through unchanged and no Range request is sent, while failures before the headers are still retried.
// retry.mjs
import { createServer } from 'node:http'
import { Agent, interceptors, request } from 'undici'
let hits = 0
const server = createServer((req, res) => {
hits++
res.writeHead(200, { 'content-length': 100, 'accept-ranges': 'bytes', etag: '"v1"' })
res.write('partial data...')
setTimeout(() => res.destroy(), 20) // drop the connection mid-body
})
await new Promise(r => server.listen(0, r))
const url = `http://localhost:${server.address().port}/file`
for (const resume of [true, false]) {
hits = 0
const agent = new Agent().compose(
interceptors.retry({ maxRetries: 2, minTimeout: 10, resume })
)
try {
const res = await request(url, { dispatcher: agent })
await res.body.text()
} catch (err) {
console.log({ resume, error: err.code, serverHits: hits })
}
await agent.close()
}
server.close()
Output:
{ resume: true, error: 'UND_ERR_REQ_RETRY', serverHits: 2 }
{ resume: false, error: 'UND_ERR_SOCKET', serverHits: 1 }
With the default, undici made a second (Range) request and then failed because our toy server doesn’t honour ranges. With resume: false, it made one request and surfaced the original socket error, which is what a proxy wants to pass on.
Other fixes in 8.14.0
- HTTP/1 sockets are destroyed on error (#6255), avoiding reuse of a broken connection.
- HTTP/2: aborted streams are reset with
CANCEL, requests can be dispatched before the server’s SETTINGS frame up to the recommended 100 streams, andAsyncLocalStoragecontext is preserved for request body chunks. - fetch preserves falsy abort reasons passed to
AbortController.abort(). - SOCKS5 proxies handle bracketed IPv6 literals.
- Cache batch operations restore the backing list in place on failure.
- WebSocket internals
kRef/kUnrefare now non-enumerable and brand-checked.
Takeaway
If you use undici’s deduplicate interceptor, upgrade to 8.14.0 now: requests with bodies are no longer merged, which closes a real cross-user data leak in shared dispatchers. While you are there, use preserveHeaders if you need the original encoding headers and resume: false for retry logic in proxies. The interceptor docs cover every option.
