Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: incorrect header check Z_DATA_ERROR #2603

Closed
jaschaio opened this issue Jan 8, 2024 · 8 comments · Fixed by #2650
Closed

Error: incorrect header check Z_DATA_ERROR #2603

jaschaio opened this issue Jan 8, 2024 · 8 comments · Fixed by #2650
Labels
bug Something isn't working

Comments

@jaschaio
Copy link

jaschaio commented Jan 8, 2024

Bug Description

I am trying to fetch a URL but it fails. It works just fine when I use node-fetch, curl or the native browser fetch. It's similar to #1271 but there is no redirect happening.

These are the response headers:

{
  'cache-control': 'no-cache',
  'content-encoding': 'deflate',
  'content-type': 'text/xml; charset=utf-8',
  date: 'Mon, 08 Jan 2024 06:12:38 GMT',
  server: 'lighttpd/1.4.45',
  'transfer-encoding': 'chunked'
}

Reproducible By

const response = await fetch( 'https://egauge90013.egaug.es/cgi-bin/egauge-show?a&E' );

const text = await response.text();

console.log( text );

Expected Behavior

I would expect the response to log into console

Logs

Instead I get this error:

TypeError: terminated
    at Fetch.onAborted (node:internal/deps/undici/undici:11279:53)
    at Fetch.emit (node:events:513:28)
    at Fetch.emit (node:domain:489:12)
    at Fetch.terminate (node:internal/deps/undici/undici:10534:14)
    at Fetch.fetchParams.controller.resume (node:internal/deps/undici/undici:11258:36)
    at 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'
  }
}

Environment

Node v20.7.0 and v18.14.2

@jaschaio jaschaio added the bug Something isn't working label Jan 8, 2024
@mcollina
Copy link
Member

mcollina commented Jan 8, 2024

Can you please set up a simple node server that reproduce the problem?

@jaschaio
Copy link
Author

jaschaio commented Jan 8, 2024

Can you please set up a simple node server that reproduce the problem?

https://codesandbox.io/p/devbox/fetch-lxhr8s

@mcollina
Copy link
Member

mcollina commented Jan 8, 2024

I don't see a server there, only the fetch client.

@ronag
Copy link
Member

ronag commented Jan 8, 2024

Probably related https://github.com/node-fetch/node-fetch/blob/8b3320d2a7c07bce4afc6b2bf6c3bbddda85b01f/src/index.js#L315

@ronag
Copy link
Member

ronag commented Jan 8, 2024

PR welcome

@jaschaio
Copy link
Author

jaschaio commented Jan 8, 2024

I don't see a server there, only the fetch client.

Sorry, I misread your question. I don't control the server so not sure what exactly they are doing in their response that is causing issues with node fetch / unidici.

@jaschaio
Copy link
Author

jaschaio commented Jan 8, 2024

Probably related https://github.com/node-fetch/node-fetch/blob/8b3320d2a7c07bce4afc6b2bf6c3bbddda85b01f/src/index.js#L315

@ronag Thanks, do you mean node-fetch has some special handling not present in unidici and that's why it works with node-fetch but not node native fetch?

@ronag
Copy link
Member

ronag commented Jan 8, 2024

Probably related https://github.com/node-fetch/node-fetch/blob/8b3320d2a7c07bce4afc6b2bf6c3bbddda85b01f/src/index.js#L315

@ronag Thanks, do you mean node-fetch has some special handling not present in unidici and that's why it works with node-fetch but not node native fetch?

Correct.

flawiddsouza added a commit to flawiddsouza/Restfox that referenced this issue Mar 22, 2024
…/GetEntityToken" fails with Error: terminated (issue seems to already be resolved at nodejs/undici#2603) - undici is what node's fetch uses behind the scenes - updating to the latest version of undici fixes the issue

Stack trace of the error I was getting:
TypeError: terminated
    at Fetch.onAborted (node:internal/deps/undici/undici:11442:53)
    at Fetch.emit (node:events:514:28)
    at Fetch.terminate (node:internal/deps/undici/undici:10695:14)
    at Fetch.resume (node:internal/deps/undici/undici:11421: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'
  }
}
flawiddsouza added a commit to flawiddsouza/Restfox that referenced this issue Mar 22, 2024
…lready be resolved at nodejs/undici#2603) - undici is what node's fetch uses behind the scenes - updating to the latest version of undici fixes the issue

Stack trace of the error I was getting when I sent a POST request to https://test.playfabapi.com/Authentication/GetEntityToken:
TypeError: terminated
    at Fetch.onAborted (node:internal/deps/undici/undici:11442:53)
    at Fetch.emit (node:events:514:28)
    at Fetch.terminate (node:internal/deps/undici/undici:10695:14)
    at Fetch.resume (node:internal/deps/undici/undici:11421: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'
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants