@whatwg-node/node-fetch 0.7.15-alpha-20250324152250-8ff5817526a9be72fff5e836f5e53a8d1b44cb64 → 0.7.15-alpha-20250324173008-e214682794a80d23e60fa5a3ee070fdb4871da83

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.
package/cjs/Body.js CHANGED
@@ -6,7 +6,6 @@ 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");
10
9
  const busboy_1 = tslib_1.__importDefault(require("busboy"));
11
10
  const promise_helpers_1 = require("@whatwg-node/promise-helpers");
12
11
  const Blob_js_1 = require("./Blob.js");
@@ -407,27 +406,17 @@ function processBodyInit(bodyInit, signal) {
407
406
  };
408
407
  }
409
408
  if (bodyInit instanceof node_http_1.IncomingMessage) {
410
- const passthrough = new node_stream_1.PassThrough({
409
+ const passThrough = bodyInit.pipe(new node_stream_1.PassThrough({
411
410
  signal,
412
- });
413
- (0, promises_1.pipeline)(bodyInit, passthrough, {
411
+ }), {
414
412
  end: true,
415
- signal,
416
- })
417
- .then(() => {
418
- if (!bodyInit.destroyed) {
419
- bodyInit.resume();
420
- }
421
- })
422
- .catch(e => {
423
- passthrough.destroy(e);
424
413
  });
425
414
  return {
426
415
  bodyType: BodyInitType.Readable,
427
416
  contentType: null,
428
417
  contentLength: null,
429
418
  bodyFactory() {
430
- return new ReadableStream_js_1.PonyfillReadableStream(passthrough);
419
+ return new ReadableStream_js_1.PonyfillReadableStream(passThrough);
431
420
  },
432
421
  };
433
422
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PonyfillReadableStream = void 0;
4
4
  const node_buffer_1 = require("node:buffer");
5
5
  const node_stream_1 = require("node:stream");
6
+ const promise_helpers_1 = require("@whatwg-node/promise-helpers");
6
7
  const utils_js_1 = require("./utils.js");
7
8
  function createController(desiredSize, readable) {
8
9
  let chunks = [];
@@ -66,20 +67,31 @@ class PonyfillReadableStream {
66
67
  else {
67
68
  let started = false;
68
69
  let ongoing = false;
69
- const readImpl = async (desiredSize) => {
70
+ const handleStart = (desiredSize) => {
70
71
  if (!started) {
71
72
  const controller = createController(desiredSize, this.readable);
72
73
  started = true;
73
- await underlyingSource?.start?.(controller);
74
- controller._flush();
75
- if (controller._closed) {
74
+ return (0, promise_helpers_1.handleMaybePromise)(() => underlyingSource?.start?.(controller), () => {
75
+ controller._flush();
76
+ if (controller._closed) {
77
+ return false;
78
+ }
79
+ return true;
80
+ });
81
+ }
82
+ return true;
83
+ };
84
+ const readImpl = (desiredSize) => {
85
+ return (0, promise_helpers_1.handleMaybePromise)(() => handleStart(desiredSize), shouldContinue => {
86
+ if (!shouldContinue) {
76
87
  return;
77
88
  }
78
- }
79
- const controller = createController(desiredSize, this.readable);
80
- await underlyingSource?.pull?.(controller);
81
- controller._flush();
82
- ongoing = false;
89
+ const controller = createController(desiredSize, this.readable);
90
+ return (0, promise_helpers_1.handleMaybePromise)(() => underlyingSource?.pull?.(controller), () => {
91
+ controller._flush();
92
+ ongoing = false;
93
+ });
94
+ });
83
95
  };
84
96
  this.readable = new node_stream_1.Readable({
85
97
  read(desiredSize) {
package/esm/Body.js CHANGED
@@ -2,7 +2,6 @@
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';
6
5
  import busboy from 'busboy';
7
6
  import { handleMaybePromise } from '@whatwg-node/promise-helpers';
8
7
  import { hasArrayBufferMethod, hasBufferMethod, hasBytesMethod, PonyfillBlob } from './Blob.js';
@@ -402,27 +401,17 @@ function processBodyInit(bodyInit, signal) {
402
401
  };
403
402
  }
404
403
  if (bodyInit instanceof IncomingMessage) {
405
- const passthrough = new PassThrough({
404
+ const passThrough = bodyInit.pipe(new PassThrough({
406
405
  signal,
407
- });
408
- pipeline(bodyInit, passthrough, {
406
+ }), {
409
407
  end: true,
410
- signal,
411
- })
412
- .then(() => {
413
- if (!bodyInit.destroyed) {
414
- bodyInit.resume();
415
- }
416
- })
417
- .catch(e => {
418
- passthrough.destroy(e);
419
408
  });
420
409
  return {
421
410
  bodyType: BodyInitType.Readable,
422
411
  contentType: null,
423
412
  contentLength: null,
424
413
  bodyFactory() {
425
- return new PonyfillReadableStream(passthrough);
414
+ return new PonyfillReadableStream(passThrough);
426
415
  },
427
416
  };
428
417
  }
@@ -1,5 +1,6 @@
1
1
  import { Buffer } from 'node:buffer';
2
2
  import { Readable } from 'node:stream';
3
+ import { handleMaybePromise } from '@whatwg-node/promise-helpers';
3
4
  import { fakePromise } from './utils.js';
4
5
  function createController(desiredSize, readable) {
5
6
  let chunks = [];
@@ -63,20 +64,31 @@ export class PonyfillReadableStream {
63
64
  else {
64
65
  let started = false;
65
66
  let ongoing = false;
66
- const readImpl = async (desiredSize) => {
67
+ const handleStart = (desiredSize) => {
67
68
  if (!started) {
68
69
  const controller = createController(desiredSize, this.readable);
69
70
  started = true;
70
- await underlyingSource?.start?.(controller);
71
- controller._flush();
72
- if (controller._closed) {
71
+ return handleMaybePromise(() => underlyingSource?.start?.(controller), () => {
72
+ controller._flush();
73
+ if (controller._closed) {
74
+ return false;
75
+ }
76
+ return true;
77
+ });
78
+ }
79
+ return true;
80
+ };
81
+ const readImpl = (desiredSize) => {
82
+ return handleMaybePromise(() => handleStart(desiredSize), shouldContinue => {
83
+ if (!shouldContinue) {
73
84
  return;
74
85
  }
75
- }
76
- const controller = createController(desiredSize, this.readable);
77
- await underlyingSource?.pull?.(controller);
78
- controller._flush();
79
- ongoing = false;
86
+ const controller = createController(desiredSize, this.readable);
87
+ return handleMaybePromise(() => underlyingSource?.pull?.(controller), () => {
88
+ controller._flush();
89
+ ongoing = false;
90
+ });
91
+ });
80
92
  };
81
93
  this.readable = new Readable({
82
94
  read(desiredSize) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.7.15-alpha-20250324152250-8ff5817526a9be72fff5e836f5e53a8d1b44cb64",
3
+ "version": "0.7.15-alpha-20250324173008-e214682794a80d23e60fa5a3ee070fdb4871da83",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {