node-fetch+2.6.7.patch 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. diff --git a/node_modules/node-fetch/lib/index.js b/node_modules/node-fetch/lib/index.js
  2. index e5b04f1..8c80924 100644
  3. --- a/node_modules/node-fetch/lib/index.js
  4. +++ b/node_modules/node-fetch/lib/index.js
  5. @@ -545,8 +545,8 @@ function clone(instance) {
  6. // tee instance body
  7. p1 = new PassThrough();
  8. p2 = new PassThrough();
  9. - body.pipe(p1);
  10. - body.pipe(p2);
  11. + Stream.pipeline(body, p1, () => {});
  12. + Stream.pipeline(body, p2, () => {});
  13. // set instance body to teed body and return the other teed body
  14. instance[INTERNALS].body = p1;
  15. body = p2;
  16. @@ -648,14 +648,14 @@ function writeToStream(dest, instance) {
  17. // body is null
  18. dest.end();
  19. } else if (isBlob(body)) {
  20. - body.stream().pipe(dest);
  21. + Stream.pipeline(body.stream(), dest, () => {});
  22. } else if (Buffer.isBuffer(body)) {
  23. // body is buffer
  24. dest.write(body);
  25. dest.end();
  26. } else {
  27. // body is stream
  28. - body.pipe(dest);
  29. + Stream.pipeline(body, dest, () => {});
  30. }
  31. }
  32. @@ -1594,7 +1594,7 @@ function fetch(url, opts) {
  33. res.once('end', function () {
  34. if (signal) signal.removeEventListener('abort', abortAndFinalize);
  35. });
  36. - let body = res.pipe(new PassThrough$1());
  37. + let body = new PassThrough$1(); setTimeout(() => Stream.pipeline(res, body, (err) => { if (err) req.abort() }), 0); // Note: let the call-site attach event handler to "body" before we start streaming.
  38. const response_options = {
  39. url: request.url,
  40. @@ -1635,7 +1635,7 @@ function fetch(url, opts) {
  41. // for gzip
  42. if (codings == 'gzip' || codings == 'x-gzip') {
  43. - body = body.pipe(zlib.createGunzip(zlibOptions));
  44. + const bodyGzip = zlib.createGunzip(zlibOptions); Stream.pipeline(body, bodyGzip, () => {}); body = bodyGzip;
  45. response = new Response(body, response_options);
  46. resolve(response);
  47. return;
  48. @@ -1645,13 +1645,13 @@ function fetch(url, opts) {
  49. if (codings == 'deflate' || codings == 'x-deflate') {
  50. // handle the infamous raw deflate response from old servers
  51. // a hack for old IIS and Apache servers
  52. - const raw = res.pipe(new PassThrough$1());
  53. + const raw = new PassThrough$1(); setTimeout(() => Stream.pipeline(res, raw, () => {}), 0); // Note: delay piping into "raw" until we start piping into "body".
  54. raw.once('data', function (chunk) {
  55. // see http://stackoverflow.com/questions/37519828
  56. if ((chunk[0] & 0x0F) === 0x08) {
  57. - body = body.pipe(zlib.createInflate());
  58. + const bodyDeflate = zlib.createInflate(); Stream.pipeline(body, bodyDeflate, () => {}); body = bodyDeflate;
  59. } else {
  60. - body = body.pipe(zlib.createInflateRaw());
  61. + const bodyDeflate = zlib.createInflateRaw(); Stream.pipeline(body, bodyDeflate, () => {}); body = bodyDeflate;
  62. }
  63. response = new Response(body, response_options);
  64. resolve(response);
  65. @@ -1661,7 +1661,7 @@ function fetch(url, opts) {
  66. // for br
  67. if (codings == 'br' && typeof zlib.createBrotliDecompress === 'function') {
  68. - body = body.pipe(zlib.createBrotliDecompress());
  69. + const bodyBrotli = zlib.createBrotliDecompress(); Stream.pipeline(body, bodyBrotli, () => {}); body = bodyBrotli;
  70. response = new Response(body, response_options);
  71. resolve(response);
  72. return;