Skip to content

Fetch with integrity option fails on "TypeError: response.arrayBuffer is not a function" #1594

@jelmervdl

Description

@jelmervdl

Version

18.4.0

Platform

Darwin MPB16.local 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 x86_64

Subsystem

fetch

What steps will reproduce the bug?

Using fetch() with the integrity option seems to consistently fail, throwing from an internal library function.

Simplest example I could come up with:

async function test() {
	const response = await fetch('https://storage.googleapis.com/bergamot-models-sandbox/0.3.3/enes/qualityModel.enes.bin', {
		integrity: 'sha256-zhQfjp5Qpe9NjjJDonSxc03FMvaWN5Sohp3ONay1Q8I='
	})

	console.log(response);
}

test();

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

Seems to be consistent. Without the integrity option for the request, it succeeds. But with it, it throws. I have not tried it with different hosts.

What is the expected behavior?

The above script retuning and printing the Response object instead of throwing.

What do you see instead?

(node:22831) 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)
node:internal/deps/undici/undici:5555
          p.reject(Object.assign(new TypeError("fetch failed"), { cause: response.error }));
                                 ^

TypeError: fetch failed
    at Object.processResponse (node:internal/deps/undici/undici:5555:34)
    at node:internal/deps/undici/undici:5877:42
    at node:internal/process/task_queues:140:7
    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: TypeError: response.arrayBuffer is not a function
      at mainFetch (node:internal/deps/undici/undici:5773:38)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions