Skip to content

node v18.6.0. - TypeError: The "source" argument must be an instance of Response or an Promise resolving to Response. Received an instance of Response #43925

Description

@8bcb

Version

v18.6.0

Platform

Darwin Asias-MacBook-Air.local 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 arm64

Subsystem

No response

What steps will reproduce the bug?

Hey :)
I've upgraded node to 18.6.0 and started receiving following typescript error (I work on the latest typescript version 4.7.4:

TypeError: The "source" argument must be an instance of Response or an Promise resolving to Response. Received an instance of Response

Error occurs when calling wasm method:

await WebAssembly.compileStreaming(wasmResponse);

API:

function WebAssembly.compileStreaming(source: Response | PromiseLike<Response>): Promise<WebAssembly.Module>

This is how I generate the response:

function generateResponse(wasmBinary: Buffer): Response {
  const init = { status: 200, statusText: 'OK', headers: { 'Content-Type': 'application/wasm' } };
  return new Response(wasmBinary, init);
}

It was working fine under node v16.5.0. I assume it may have sth to do with undici providing default fetch to node?

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

No response

What is the expected behavior?

No response

What do you see instead?

TypeError: The "source" argument must be an instance of Response or an Promise resolving to Response. Received an instance of Response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions