Skip to content

Commit d4efd92

Browse files
fix: make FetchResponse type compatible with a native Response object
1 parent 84a5acc commit d4efd92

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/fetch-error-handler/lib/create-handler.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { Writable } = require('node:stream');
1212
*/
1313

1414
/**
15-
* @typedef {object} FetchResponseBody
15+
* @typedef {object} NodeFetchResponseBody
1616
* @property {(stream: Writable) => void} [pipe]
1717
* A function to pipe a response body stream.
1818
*/
@@ -25,7 +25,7 @@ const { Writable } = require('node:stream');
2525
* The response HTTP status code.
2626
* @property {string} url
2727
* The URL of the response.
28-
* @property {FetchResponseBody} body
28+
* @property {NodeFetchResponseBody | ReadableStream<Uint8Array> | null} body
2929
* A representation of the response body.
3030
*/
3131

@@ -205,6 +205,8 @@ function createFetchErrorHandler(options = {}) {
205205
// body so we don't introduce a memory leak.
206206
if (
207207
isFetchResponse(response) &&
208+
response.body &&
209+
'pipe' in response.body &&
208210
typeof response.body.pipe === 'function'
209211
) {
210212
response.body.pipe(new BlackHoleStream());

0 commit comments

Comments
 (0)