-
-
Notifications
You must be signed in to change notification settings - Fork 687
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
fetch is terminated with a Z_DATA_ERROR when fetching a gzip, deflate compressed response from the server.
Reproducible By
Here's a 0 dependency reproduction:
- https://github.com/kettanaito/undici-gzip-deflate
node ./index.js
Here's a copy-pastable reproduction:
import http from 'node:http'
import zlib from 'node:zlib'
const server = new http.Server((req, res) => {
res.setHeader('content-encoding', 'gzip, deflate')
res.end(zlib.deflateSync(zlib.gzipSync('hello world')))
})
server.listen(56789, async () => {
const response = await fetch('http://localhost:56789/', {
headers: { 'accept-encoding': 'gzip, deflate' },
})
const text = await response.text()
console.assert(text === 'hello world')
})Expected Behavior
- Fetch happens without errors.
await response.text()returns a decompressed response string'hello world'.
Logs & Screenshots
node:internal/deps/undici/undici:11190
fetchParams.controller.controller.error(new TypeError("terminated", {
^
TypeError: terminated
at Fetch.onAborted (node:internal/deps/undici/undici:11190:53)
at Fetch.emit (node:events:517:28)
at Fetch.terminate (node:internal/deps/undici/undici:10375:14)
at fetchParams.controller.resume (node:internal/deps/undici/undici:11167:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[cause]: Error: incorrect header check
at Zlib.zlibOnError [as onerror] (node:zlib:189:17) {
errno: -3,
code: 'Z_DATA_ERROR'
}
}
Node.js v18.20.3
Environment
Reproducible on all versions of Node:
- 18.20.3
- 20.11.0
- 22.3.0
- 23.0.0
mikicho
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working