@whatwg-node/node-fetch 0.7.15 → 0.7.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/cjs/Body.js +10 -3
  2. package/esm/Body.js +10 -3
  3. package/package.json +1 -1
package/cjs/Body.js CHANGED
@@ -6,6 +6,7 @@ const tslib_1 = require("tslib");
6
6
  const node_buffer_1 = require("node:buffer");
7
7
  const node_http_1 = require("node:http");
8
8
  const node_stream_1 = require("node:stream");
9
+ const promises_1 = require("node:stream/promises");
9
10
  const busboy_1 = tslib_1.__importDefault(require("busboy"));
10
11
  const promise_helpers_1 = require("@whatwg-node/promise-helpers");
11
12
  const Blob_js_1 = require("./Blob.js");
@@ -401,11 +402,17 @@ function processBodyInit(bodyInit, signal) {
401
402
  };
402
403
  }
403
404
  if (bodyInit instanceof node_http_1.IncomingMessage) {
404
- const passThrough = bodyInit.pipe(new node_stream_1.PassThrough({
405
+ const passThrough = new node_stream_1.PassThrough({
405
406
  signal,
406
- }), {
407
- end: true,
408
407
  });
408
+ if (signal) {
409
+ (0, promises_1.pipeline)(bodyInit, passThrough, {
410
+ signal,
411
+ end: true,
412
+ }).catch(e => {
413
+ passThrough.destroy(e);
414
+ });
415
+ }
409
416
  return {
410
417
  bodyType: BodyInitType.Readable,
411
418
  contentType: null,
package/esm/Body.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { Buffer } from 'node:buffer';
3
3
  import { IncomingMessage } from 'node:http';
4
4
  import { PassThrough, Readable } from 'node:stream';
5
+ import { pipeline } from 'node:stream/promises';
5
6
  import busboy from 'busboy';
6
7
  import { handleMaybePromise } from '@whatwg-node/promise-helpers';
7
8
  import { hasArrayBufferMethod, hasBufferMethod, hasBytesMethod, PonyfillBlob } from './Blob.js';
@@ -396,11 +397,17 @@ function processBodyInit(bodyInit, signal) {
396
397
  };
397
398
  }
398
399
  if (bodyInit instanceof IncomingMessage) {
399
- const passThrough = bodyInit.pipe(new PassThrough({
400
+ const passThrough = new PassThrough({
400
401
  signal,
401
- }), {
402
- end: true,
403
402
  });
403
+ if (signal) {
404
+ pipeline(bodyInit, passThrough, {
405
+ signal,
406
+ end: true,
407
+ }).catch(e => {
408
+ passThrough.destroy(e);
409
+ });
410
+ }
404
411
  return {
405
412
  bodyType: BodyInitType.Readable,
406
413
  contentType: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.7.15",
3
+ "version": "0.7.16",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {