axios 1.7.0-beta.0 → 1.7.0-beta.1

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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ # [1.7.0-beta.1](https://github.com/axios/axios/compare/v1.7.0-beta.0...v1.7.0-beta.1) (2024-05-07)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **core/axios:** handle un-writable error stack ([#6362](https://github.com/axios/axios/issues/6362)) ([81e0455](https://github.com/axios/axios/commit/81e0455b7b57fbaf2be16a73ebe0e6591cc6d8f9))
9
+ * **fetch:** fix cases when ReadableStream or Response.body are not available; ([#6377](https://github.com/axios/axios/issues/6377)) ([d1d359d](https://github.com/axios/axios/commit/d1d359da347704e8b28d768e61515a3e96c5b072))
10
+ * **fetch:** treat fetch-related TypeError as an AxiosError.ERR_NETWORK error; ([#6380](https://github.com/axios/axios/issues/6380)) ([bb5f9a5](https://github.com/axios/axios/commit/bb5f9a5ab768452de9e166dc28d0ffc234245ef1))
11
+
12
+ ### Contributors to this release
13
+
14
+ - <img src="https://avatars.githubusercontent.com/u/16711696?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Alexandre ABRIOUX](https://github.com/alexandre-abrioux "+56/-6 (#6362 )")
15
+ - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+42/-17 (#6380 #6377 )")
16
+
3
17
  # [1.7.0-beta.0](https://github.com/axios/axios/compare/v1.6.8...v1.7.0-beta.0) (2024-04-28)
4
18
 
5
19
 
package/dist/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.7.0-beta.0 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.7.0-beta.1 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -3226,7 +3226,8 @@
3226
3226
  };
3227
3227
  };
3228
3228
  var isFetchSupported = typeof fetch !== 'undefined';
3229
- var supportsRequestStreams = isFetchSupported && function () {
3229
+ var isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
3230
+ var supportsRequestStream = isReadableStreamSupported && function () {
3230
3231
  var duplexAccessed = false;
3231
3232
  var hasContentType = new Request(platform.origin, {
3232
3233
  body: new ReadableStream(),
@@ -3239,18 +3240,27 @@
3239
3240
  return duplexAccessed && !hasContentType;
3240
3241
  }();
3241
3242
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
3243
+ var supportsResponseStream = isReadableStreamSupported && !!function () {
3244
+ try {
3245
+ return utils$1.isReadableStream(new Response('').body);
3246
+ } catch (err) {
3247
+ // return undefined
3248
+ }
3249
+ }();
3242
3250
  var resolvers = {
3243
- stream: function stream(res) {
3251
+ stream: supportsResponseStream && function (res) {
3244
3252
  return res.body;
3245
3253
  }
3246
3254
  };
3247
- isFetchSupported && ['text', 'arrayBuffer', 'blob', 'formData'].forEach(function (type) {
3248
- return [resolvers[type] = utils$1.isFunction(Response.prototype[type]) ? function (res) {
3249
- return res[type]();
3250
- } : function (_, config) {
3251
- throw new AxiosError("Response type ".concat(type, " is not supported"), AxiosError.ERR_NOT_SUPPORT, config);
3252
- }];
3253
- });
3255
+ isFetchSupported && function (res) {
3256
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(function (type) {
3257
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? function (res) {
3258
+ return res[type]();
3259
+ } : function (_, config) {
3260
+ throw new AxiosError("Response type '".concat(type, "' is not supported"), AxiosError.ERR_NOT_SUPPORT, config);
3261
+ });
3262
+ });
3263
+ }(new Response());
3254
3264
  var getBodyLength = /*#__PURE__*/function () {
3255
3265
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(body) {
3256
3266
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -3316,9 +3326,9 @@
3316
3326
  return _ref2.apply(this, arguments);
3317
3327
  };
3318
3328
  }();
3319
- var fetchAdapter = ( /*#__PURE__*/(function () {
3329
+ var fetchAdapter = isFetchSupported && ( /*#__PURE__*/function () {
3320
3330
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(config) {
3321
- var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, _ref4, _ref5, composedSignal, stopTimeout, finished, request, onFinish, requestContentLength, _request, contentTypeHeader, response, isStreamResponse, options, responseContentLength, responseData, code;
3331
+ var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, _ref4, _ref5, composedSignal, stopTimeout, finished, request, onFinish, requestContentLength, _request, contentTypeHeader, response, isStreamResponse, options, responseContentLength, responseData;
3322
3332
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
3323
3333
  while (1) switch (_context3.prev = _context3.next) {
3324
3334
  case 0:
@@ -3332,7 +3342,7 @@
3332
3342
  finished = true;
3333
3343
  };
3334
3344
  _context3.prev = 4;
3335
- if (!(onUploadProgress && supportsRequestStreams && method !== 'get' && method !== 'head')) {
3345
+ if (!(onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head')) {
3336
3346
  _context3.next = 12;
3337
3347
  break;
3338
3348
  }
@@ -3366,7 +3376,7 @@
3366
3376
  case 16:
3367
3377
  response = _context3.sent;
3368
3378
  isStreamResponse = responseType === 'stream' || responseType === 'response';
3369
- if (onDownloadProgress || isStreamResponse) {
3379
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
3370
3380
  options = {};
3371
3381
  Object.getOwnPropertyNames(response).forEach(function (prop) {
3372
3382
  options[prop] = response[prop];
@@ -3398,11 +3408,15 @@
3398
3408
  _context3.prev = 30;
3399
3409
  _context3.t0 = _context3["catch"](4);
3400
3410
  onFinish();
3401
- code = _context3.t0.code;
3402
- if (_context3.t0.name === 'NetworkError') {
3403
- code = AxiosError.ERR_NETWORK;
3411
+ if (!(_context3.t0 && _context3.t0.name === 'TypeError' && /fetch/i.test(_context3.t0.message))) {
3412
+ _context3.next = 35;
3413
+ break;
3404
3414
  }
3405
- throw AxiosError.from(_context3.t0, code, config, request);
3415
+ throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), {
3416
+ cause: _context3.t0.cause || _context3.t0
3417
+ });
3418
+ case 35:
3419
+ throw AxiosError.from(_context3.t0, _context3.t0 && _context3.t0.code, config, request);
3406
3420
  case 36:
3407
3421
  case "end":
3408
3422
  return _context3.stop();
@@ -3412,7 +3426,7 @@
3412
3426
  return function (_x4) {
3413
3427
  return _ref3.apply(this, arguments);
3414
3428
  };
3415
- })());
3429
+ }());
3416
3430
 
3417
3431
  var knownAdapters = {
3418
3432
  http: httpAdapter,
@@ -3531,7 +3545,7 @@
3531
3545
  });
3532
3546
  }
3533
3547
 
3534
- var VERSION = "1.7.0-beta.0";
3548
+ var VERSION = "1.7.0-beta.1";
3535
3549
 
3536
3550
  var validators$1 = {};
3537
3551
 
@@ -3656,11 +3670,15 @@
3656
3670
 
3657
3671
  // slice off the Error: ... line
3658
3672
  stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3659
- if (!_context.t0.stack) {
3660
- _context.t0.stack = stack;
3661
- // match without the 2 top stack lines
3662
- } else if (stack && !String(_context.t0.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3663
- _context.t0.stack += '\n' + stack;
3673
+ try {
3674
+ if (!_context.t0.stack) {
3675
+ _context.t0.stack = stack;
3676
+ // match without the 2 top stack lines
3677
+ } else if (stack && !String(_context.t0.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3678
+ _context.t0.stack += '\n' + stack;
3679
+ }
3680
+ } catch (e) {
3681
+ // ignore the case where "stack" is an un-writable property
3664
3682
  }
3665
3683
  }
3666
3684
  throw _context.t0;