Skip to content

Uncaught exception on fetch (related to zlib, Z_BUF_ERROR) #43868

Description

@coyotte508

Version

18.6.0

Platform

Linux pop-os 5.17.15-76051715-generic #202206141358165591911622.04~1db9e34 SMP PREEMPT Wed Jun 22 19 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

undici

What steps will reproduce the bug?

async function test() {
    const x = await fetch("http://www.sinlenoble.fr/solidarite/le-ccas");
    const y = await x.text();
}

test().then(() => process.exit(0), () => process.exit(1))

process.on("unhandledRejection", (r) => console.log("undhanled rejection", r))
process.on("uncaughtException", (r) => console.log("uncaught exception", r))

Output:

(node:18923) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
uncaught exception Error: unexpected end of file
    at Zlib.zlibOnError [as onerror] (node:zlib:189:17) {
  errno: -5,
  code: 'Z_BUF_ERROR'
}

How often does it reproduce? Is there a required condition?

Always, but it may go away if the remote site used for testing changes its code/configuration.

What is the expected behavior?

If there is an error with fetch, it should bubble inside the promise to be caught from the caller, instead of triggering an uncaught exception.

What do you see instead?

uncaught exception Error: unexpected end of file
    at Zlib.zlibOnError [as onerror] (node:zlib:189:17) {
  errno: -5,
  code: 'Z_BUF_ERROR'
}

Additional information

This is not the only site that triggered this

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.errorsIssues and PRs related to JavaScript errors originating in Node.js core.fetchIssues and PRs related to the Fetch API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions