@whatwg-node/node-fetch 0.7.15-alpha-20250324112015-2e11b9fc0d1303d275a3ae5587de21d9d5daffba → 0.7.15-alpha-20250324114941-a4f8cfea938b66f893b1401a217715f2e5d80dd1

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 +14 -3
  2. package/esm/Body.js +14 -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");
@@ -406,11 +407,21 @@ function processBodyInit(bodyInit, signal) {
406
407
  };
407
408
  }
408
409
  if (bodyInit instanceof node_http_1.IncomingMessage) {
409
- const passthrough = (bodyInit = bodyInit.pipe(new node_stream_1.PassThrough({
410
+ const passthrough = new node_stream_1.PassThrough({
410
411
  signal,
411
- }), {
412
+ });
413
+ (0, promises_1.pipeline)(bodyInit, passthrough, {
412
414
  end: true,
413
- }));
415
+ signal,
416
+ })
417
+ .then(() => {
418
+ if (!bodyInit.destroyed) {
419
+ bodyInit.resume();
420
+ }
421
+ })
422
+ .catch(e => {
423
+ passthrough.destroy(e);
424
+ });
414
425
  return {
415
426
  bodyType: BodyInitType.Readable,
416
427
  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';
@@ -401,11 +402,21 @@ function processBodyInit(bodyInit, signal) {
401
402
  };
402
403
  }
403
404
  if (bodyInit instanceof IncomingMessage) {
404
- const passthrough = (bodyInit = bodyInit.pipe(new PassThrough({
405
+ const passthrough = new PassThrough({
405
406
  signal,
406
- }), {
407
+ });
408
+ pipeline(bodyInit, passthrough, {
407
409
  end: true,
408
- }));
410
+ signal,
411
+ })
412
+ .then(() => {
413
+ if (!bodyInit.destroyed) {
414
+ bodyInit.resume();
415
+ }
416
+ })
417
+ .catch(e => {
418
+ passthrough.destroy(e);
419
+ });
409
420
  return {
410
421
  bodyType: BodyInitType.Readable,
411
422
  contentType: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.7.15-alpha-20250324112015-2e11b9fc0d1303d275a3ae5587de21d9d5daffba",
3
+ "version": "0.7.15-alpha-20250324114941-a4f8cfea938b66f893b1401a217715f2e5d80dd1",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {