axios 0.33.0 → 0.34.0
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/CHANGELOG.md +20 -0
- package/README.md +70 -1
- package/dist/axios.js +177 -27
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/esm/axios.js +177 -27
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/index.d.ts +5 -1
- package/lib/adapters/http.js +54 -5
- package/lib/adapters/xhr.js +2 -2
- package/lib/cancel/fromSignal.js +20 -0
- package/lib/core/Axios.js +78 -10
- package/lib/core/dispatchRequest.js +5 -4
- package/lib/core/mergeConfig.js +7 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/shouldBypassProxy.js +212 -1
- package/lib/helpers/toFormData.js +35 -8
- package/lib/utils.js +33 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased — next v0 minor
|
|
4
|
+
|
|
5
|
+
These changes improve error handling, cancellation context, and request header typing.
|
|
6
|
+
|
|
7
|
+
### ⚠️ Breaking Changes & Deprecations
|
|
8
|
+
|
|
9
|
+
* **Header types:** TypeScript now rejects header values that are Promises, functions, or objects with custom `toString()` methods. Resolve promises, call functions, or explicitly convert objects before assigning header values. This narrows previously accepted types and must ship in the next v0 minor release under the pre-1.0 compatibility policy. (__#11209__)
|
|
10
|
+
|
|
11
|
+
### 🚀 New Features
|
|
12
|
+
|
|
13
|
+
* **Caller diagnostics:** Opt in with `captureCallerStack: true` on a request or instance to append caller frames to asynchronous errors. The default is off so successful requests avoid the additional stack capture and Promise reaction. (__#11209__)
|
|
14
|
+
* **Cancellation context:** `CanceledError.reason` preserves `AbortSignal.reason`, including object and falsy values. Native and structural signals retain their identity and live getters across config merging. (__#11209__)
|
|
15
|
+
|
|
16
|
+
### 🐛 Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **Error inheritance:** Axios loads alongside read-only `Error.prototype.toJSON` properties while preserving supplied own descriptors and setters. (__#11209__)
|
|
19
|
+
* **Request interceptors:** Synchronous interceptor and dispatch failures reach response interceptors. Rejected recovery promises prevent dispatch; fulfilled recovery values are ignored and the last request config is retained. (__#11209__)
|
|
20
|
+
|
|
21
|
+
[Full Changelog](https://github.com/axios/axios/pull/11209/files)
|
|
22
|
+
|
|
3
23
|
## v0.32.0 — May 4, 2026
|
|
4
24
|
|
|
5
25
|
This release backports a comprehensive set of security and hardening fixes from the v1.x branch into v0.x, covering prototype-pollution protections, default error redaction, stricter proxy/cookie/socket handling, and one breaking change to merged config and header object prototypes.
|
package/README.md
CHANGED
|
@@ -494,7 +494,13 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
494
494
|
// supplies credentials.
|
|
495
495
|
// This will set an `Proxy-Authorization` header, overwriting any existing
|
|
496
496
|
// `Proxy-Authorization` custom headers you have set using `headers`.
|
|
497
|
-
//
|
|
497
|
+
// Set the protocol to `http` for a plaintext proxy or `https` for a TLS proxy.
|
|
498
|
+
// HTTP(S) schemes accept a trailing colon, any case, and surrounding whitespace.
|
|
499
|
+
// If omitted, the proxy connection inherits the target URL's protocol.
|
|
500
|
+
// Empty strings and non-string values also leave the target protocol unchanged.
|
|
501
|
+
// A plaintext proxy for an HTTPS target therefore requires explicit `http`.
|
|
502
|
+
// Unsupported non-empty strings (e.g. `ftp`, `https://`, or whitespace-only)
|
|
503
|
+
// reject with `ERR_BAD_OPTION_VALUE` before connecting, without a fallback.
|
|
498
504
|
proxy: {
|
|
499
505
|
protocol: 'https',
|
|
500
506
|
host: '127.0.0.1',
|
|
@@ -513,6 +519,10 @@ These are the available config options for making requests. Only the `url` is re
|
|
|
513
519
|
// an alternative way to cancel Axios requests using AbortController
|
|
514
520
|
signal: new AbortController().signal,
|
|
515
521
|
|
|
522
|
+
// Capture the request caller for asynchronous error stacks (default: false).
|
|
523
|
+
// Enable on a request or instance when the extra diagnostics are needed.
|
|
524
|
+
captureCallerStack: false,
|
|
525
|
+
|
|
516
526
|
// `decompress` indicates whether or not the response body should be decompressed
|
|
517
527
|
// automatically. If set to `true` will also remove the 'content-encoding' header
|
|
518
528
|
// from the responses objects of all decompressed responses
|
|
@@ -742,8 +752,31 @@ and when the response was fulfilled
|
|
|
742
752
|
|
|
743
753
|
Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code.
|
|
744
754
|
|
|
755
|
+
For synchronous request interceptors, a thrown error is passed to that interceptor's
|
|
756
|
+
rejection handler, when supplied. If the handler is absent, throws, or returns a
|
|
757
|
+
rejected promise, the request is rejected without being sent and response rejection
|
|
758
|
+
interceptors can handle the failure. A promise returned by a recovery handler is
|
|
759
|
+
awaited before dispatch. Recovery return values, including fulfilled promise values,
|
|
760
|
+
do not replace the last request config; that config is used for dispatch.
|
|
761
|
+
Successful synchronous interceptors still dispatch immediately.
|
|
762
|
+
|
|
745
763
|
## Handling Errors
|
|
746
764
|
|
|
765
|
+
Set `captureCallerStack: true` on a request or instance to append the original caller
|
|
766
|
+
to errors created asynchronously. Stack capture is disabled by default because it
|
|
767
|
+
adds work to every enabled request, including successful requests. When disabled,
|
|
768
|
+
Axios keeps the error's existing stack without capturing additional caller frames.
|
|
769
|
+
|
|
770
|
+
```js
|
|
771
|
+
const client = axios.create({captureCallerStack: true});
|
|
772
|
+
client.get('/user/12345');
|
|
773
|
+
// An individual request can override the instance setting.
|
|
774
|
+
client.get('/status', {captureCallerStack: false});
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
The original error and its existing stack are preserved when caller frames are
|
|
778
|
+
appended. Availability and frame counts depend on the runtime's stack support and settings.
|
|
779
|
+
|
|
747
780
|
```js
|
|
748
781
|
axios.get('/user/12345')
|
|
749
782
|
.catch(function (error) {
|
|
@@ -803,6 +836,26 @@ axios.get('/foo/bar', {
|
|
|
803
836
|
controller.abort()
|
|
804
837
|
```
|
|
805
838
|
|
|
839
|
+
On runtimes that expose `AbortSignal.reason`, Axios preserves that value in
|
|
840
|
+
`CanceledError.reason`, including objects and falsy values. Cancellation still uses
|
|
841
|
+
the `canceled` message, `ERR_CANCELED` code, and `axios.isCancel()` detection. Signals
|
|
842
|
+
without a reason continue to work and leave `error.reason` undefined.
|
|
843
|
+
Native signals and plain objects implementing `GenericAbortSignal` are retained by
|
|
844
|
+
reference when configurations are merged, preserving live getters and reason identity.
|
|
845
|
+
|
|
846
|
+
```js
|
|
847
|
+
const controller = new AbortController();
|
|
848
|
+
const reason = new Error('Replaced by a newer search');
|
|
849
|
+
|
|
850
|
+
axios.get('/search', {signal: controller.signal}).catch(function (error) {
|
|
851
|
+
if (axios.isCancel(error) && error.reason === reason) {
|
|
852
|
+
// This request was superseded.
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
controller.abort(reason);
|
|
857
|
+
```
|
|
858
|
+
|
|
806
859
|
### CancelToken `👎deprecated`
|
|
807
860
|
|
|
808
861
|
You can also cancel a request using a *CancelToken*.
|
|
@@ -1181,6 +1234,22 @@ If your environment doesn't support ES6 Promises, you can [polyfill](https://git
|
|
|
1181
1234
|
|
|
1182
1235
|
## TypeScript
|
|
1183
1236
|
|
|
1237
|
+
Request header values are strings, string arrays, numbers, or booleans. The
|
|
1238
|
+
`common` and method-specific header groups accept maps of these values. Resolve
|
|
1239
|
+
asynchronous values in a request interceptor before assigning them to headers;
|
|
1240
|
+
Promise and function values are rejected by the TypeScript declarations.
|
|
1241
|
+
|
|
1242
|
+
This is a TypeScript compatibility change for the next v0 minor release. Code that
|
|
1243
|
+
previously assigned a Promise, function, or object with a custom `toString()` method
|
|
1244
|
+
must first resolve the Promise, call the function, or explicitly convert the object
|
|
1245
|
+
to a supported header value. For example:
|
|
1246
|
+
|
|
1247
|
+
```typescript
|
|
1248
|
+
async function requestWithToken(token: Promise<string>) {
|
|
1249
|
+
return axios.get('/user', {headers: {Authorization: 'Bearer ' + await token}});
|
|
1250
|
+
}
|
|
1251
|
+
```
|
|
1252
|
+
|
|
1184
1253
|
axios includes [TypeScript](https://typescriptlang.org) definitions and a type guard for axios errors.
|
|
1185
1254
|
|
|
1186
1255
|
```typescript
|
package/dist/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.34.0 Copyright (c) 2026 Matt Zabriskie
|
|
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) :
|
|
@@ -402,6 +402,15 @@
|
|
|
402
402
|
return content;
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
+
function defineOwnProperty(target, key, value) {
|
|
406
|
+
var descriptor = Object.create(null);
|
|
407
|
+
descriptor.value = value;
|
|
408
|
+
descriptor.writable = true;
|
|
409
|
+
descriptor.enumerable = true;
|
|
410
|
+
descriptor.configurable = true;
|
|
411
|
+
Object.defineProperty(target, key, descriptor);
|
|
412
|
+
}
|
|
413
|
+
|
|
405
414
|
/**
|
|
406
415
|
* Inherit the prototype methods from one constructor into another
|
|
407
416
|
* @param {function} constructor
|
|
@@ -409,14 +418,35 @@
|
|
|
409
418
|
* @param {object} [props]
|
|
410
419
|
* @param {object} [descriptors]
|
|
411
420
|
*/
|
|
412
|
-
|
|
413
421
|
function inherits(constructor, superConstructor, props, descriptors) {
|
|
414
422
|
constructor.prototype = Object.create(
|
|
415
423
|
superConstructor.prototype,
|
|
416
424
|
descriptors
|
|
417
425
|
);
|
|
418
|
-
|
|
419
|
-
|
|
426
|
+
if (Object.prototype.hasOwnProperty.call(constructor.prototype, 'constructor')) {
|
|
427
|
+
constructor.prototype.constructor = constructor;
|
|
428
|
+
} else {
|
|
429
|
+
defineOwnProperty(constructor.prototype, 'constructor', constructor);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (props) {
|
|
433
|
+
var keys = Object.keys(props);
|
|
434
|
+
if (Object.getOwnPropertySymbols) {
|
|
435
|
+
keys = keys.concat(Object.getOwnPropertySymbols(props).filter(function(key) {
|
|
436
|
+
return Object.prototype.propertyIsEnumerable.call(props, key);
|
|
437
|
+
}));
|
|
438
|
+
}
|
|
439
|
+
keys.forEach(function(key) {
|
|
440
|
+
var value = props[key];
|
|
441
|
+
if (Object.prototype.hasOwnProperty.call(constructor.prototype, key)) {
|
|
442
|
+
constructor.prototype[key] = value;
|
|
443
|
+
} else {
|
|
444
|
+
// Assignment would invoke an inherited setter or fail on a read-only
|
|
445
|
+
// property installed by another library, such as Error.prototype.toJSON.
|
|
446
|
+
defineOwnProperty(constructor.prototype, key, value);
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
420
450
|
}
|
|
421
451
|
|
|
422
452
|
/**
|
|
@@ -779,6 +809,40 @@
|
|
|
779
809
|
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
|
780
810
|
}
|
|
781
811
|
|
|
812
|
+
var UNSAFE_OPTION_KEYS = ['__proto__', 'constructor', 'prototype'];
|
|
813
|
+
|
|
814
|
+
// Materialises the serializer options onto a null-prototype object. Reading the
|
|
815
|
+
// options from a plain object let a polluted Object.prototype supply a visitor,
|
|
816
|
+
// a depth limit, a Blob implementation or key-format flags that the caller never
|
|
817
|
+
// asked for, and also let a polluted key mask an option the caller did set.
|
|
818
|
+
// Only own, defined properties of the caller's options are carried over.
|
|
819
|
+
function toFormDataOptions(source) {
|
|
820
|
+
var options = Object.create(null);
|
|
821
|
+
|
|
822
|
+
options.metaTokens = true;
|
|
823
|
+
options.dots = false;
|
|
824
|
+
options.indexes = false;
|
|
825
|
+
|
|
826
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
827
|
+
if (source == null) {
|
|
828
|
+
return options;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
var names = Object.getOwnPropertyNames(source);
|
|
832
|
+
|
|
833
|
+
for (var i = 0; i < names.length; i++) {
|
|
834
|
+
var name = names[i];
|
|
835
|
+
|
|
836
|
+
if (UNSAFE_OPTION_KEYS.indexOf(name) !== -1 || utils.isUndefined(source[name])) {
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
options[name] = source[name];
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
return options;
|
|
844
|
+
}
|
|
845
|
+
|
|
782
846
|
/**
|
|
783
847
|
* Convert a data object to FormData
|
|
784
848
|
* @param {Object} obj
|
|
@@ -800,14 +864,7 @@
|
|
|
800
864
|
formData = formData || new (FormData$1 || FormData)();
|
|
801
865
|
|
|
802
866
|
// eslint-disable-next-line no-param-reassign
|
|
803
|
-
options =
|
|
804
|
-
metaTokens: true,
|
|
805
|
-
dots: false,
|
|
806
|
-
indexes: false
|
|
807
|
-
}, false, function defined(option, source) {
|
|
808
|
-
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
809
|
-
return !utils.isUndefined(source[option]);
|
|
810
|
-
});
|
|
867
|
+
options = toFormDataOptions(options);
|
|
811
868
|
|
|
812
869
|
var metaTokens = options.metaTokens;
|
|
813
870
|
// eslint-disable-next-line no-use-before-define
|
|
@@ -1519,6 +1576,23 @@
|
|
|
1519
1576
|
|
|
1520
1577
|
var CanceledError_1 = CanceledError;
|
|
1521
1578
|
|
|
1579
|
+
var fromSignal = function fromSignal(signal, config, request) {
|
|
1580
|
+
var error = new CanceledError_1(null, config, request);
|
|
1581
|
+
|
|
1582
|
+
if (signal) {
|
|
1583
|
+
try {
|
|
1584
|
+
var reason = signal.reason;
|
|
1585
|
+
if (reason !== undefined) {
|
|
1586
|
+
error.reason = reason;
|
|
1587
|
+
}
|
|
1588
|
+
} catch (e) {
|
|
1589
|
+
// A custom signal getter must not prevent cancellation.
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
return error;
|
|
1594
|
+
};
|
|
1595
|
+
|
|
1522
1596
|
var parseProtocol = function parseProtocol(url) {
|
|
1523
1597
|
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
1524
1598
|
return match && match[1] || '';
|
|
@@ -1772,7 +1846,7 @@
|
|
|
1772
1846
|
}
|
|
1773
1847
|
reject(
|
|
1774
1848
|
!cancel || cancel.type
|
|
1775
|
-
?
|
|
1849
|
+
? fromSignal(config.signal, config, request)
|
|
1776
1850
|
: cancel
|
|
1777
1851
|
);
|
|
1778
1852
|
request.abort();
|
|
@@ -2036,7 +2110,7 @@
|
|
|
2036
2110
|
}
|
|
2037
2111
|
|
|
2038
2112
|
if (config.signal && config.signal.aborted) {
|
|
2039
|
-
throw
|
|
2113
|
+
throw fromSignal(config.signal, config);
|
|
2040
2114
|
}
|
|
2041
2115
|
}
|
|
2042
2116
|
|
|
@@ -2049,8 +2123,9 @@
|
|
|
2049
2123
|
var dispatchRequest = function dispatchRequest(config) {
|
|
2050
2124
|
throwIfCancellationRequested(config);
|
|
2051
2125
|
|
|
2052
|
-
// Ensure headers exist
|
|
2053
|
-
|
|
2126
|
+
// Ensure headers exist. A request interceptor may return a replacement config
|
|
2127
|
+
// that inherits from Object.prototype, so only an own headers value is used.
|
|
2128
|
+
config.headers = (utils.hasOwnProperty(config, 'headers') && config.headers) || {};
|
|
2054
2129
|
|
|
2055
2130
|
// Transform request data
|
|
2056
2131
|
config.data = transformData.call(
|
|
@@ -2183,6 +2258,11 @@
|
|
|
2183
2258
|
}
|
|
2184
2259
|
}
|
|
2185
2260
|
|
|
2261
|
+
function defaultToConfig2Reference(prop) {
|
|
2262
|
+
var value = getOwn(config2, prop);
|
|
2263
|
+
return utils.isUndefined(value) ? getOwn(config1, prop) : value;
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2186
2266
|
// eslint-disable-next-line consistent-return
|
|
2187
2267
|
function mergeDirectKeys(prop) {
|
|
2188
2268
|
if (hasOwn(config2, prop)) {
|
|
@@ -2218,6 +2298,8 @@
|
|
|
2218
2298
|
'httpAgent': defaultToConfig2,
|
|
2219
2299
|
'httpsAgent': defaultToConfig2,
|
|
2220
2300
|
'cancelToken': defaultToConfig2,
|
|
2301
|
+
// Signals are live objects; cloning them snapshots getters and reasons.
|
|
2302
|
+
'signal': defaultToConfig2Reference,
|
|
2221
2303
|
'socketPath': defaultToConfig2,
|
|
2222
2304
|
'allowedSocketPaths': defaultToConfig2,
|
|
2223
2305
|
'responseEncoding': defaultToConfig2,
|
|
@@ -2237,7 +2319,7 @@
|
|
|
2237
2319
|
};
|
|
2238
2320
|
|
|
2239
2321
|
var data = {
|
|
2240
|
-
"version": "0.
|
|
2322
|
+
"version": "0.34.0"
|
|
2241
2323
|
};
|
|
2242
2324
|
|
|
2243
2325
|
var VERSION = data.version;
|
|
@@ -2326,6 +2408,56 @@
|
|
|
2326
2408
|
};
|
|
2327
2409
|
|
|
2328
2410
|
var validators = validator.validators;
|
|
2411
|
+
|
|
2412
|
+
function captureCallerStack(boundary) {
|
|
2413
|
+
var caller = {};
|
|
2414
|
+
try {
|
|
2415
|
+
if (Error.captureStackTrace) {
|
|
2416
|
+
Error.captureStackTrace(caller, boundary);
|
|
2417
|
+
} else {
|
|
2418
|
+
caller = new Error();
|
|
2419
|
+
}
|
|
2420
|
+
} catch (e) {
|
|
2421
|
+
// Stack hooks must not prevent a request from being sent.
|
|
2422
|
+
}
|
|
2423
|
+
return caller;
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
function attachCallerStack(promise, caller) {
|
|
2427
|
+
if (!caller) {
|
|
2428
|
+
return promise;
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
return promise.then(null, function onRequestRejected(error) {
|
|
2432
|
+
try {
|
|
2433
|
+
if (error instanceof Error || Object.prototype.toString.call(error) === '[object Error]') {
|
|
2434
|
+
// Capture at dispatch time, but only format the stack on failure.
|
|
2435
|
+
// Capturing in this callback would lose callers using .then/.catch.
|
|
2436
|
+
var stack = caller.stack;
|
|
2437
|
+
if (typeof stack === 'string') {
|
|
2438
|
+
var newline = stack.indexOf('\n');
|
|
2439
|
+
stack = newline === -1 ? '' : stack.slice(newline + 1);
|
|
2440
|
+
var original = error.stack;
|
|
2441
|
+
if (stack && (original === undefined || original === null || original === '')) {
|
|
2442
|
+
error.stack = stack;
|
|
2443
|
+
} else if (stack && typeof original === 'string' && original.indexOf(stack) === -1) {
|
|
2444
|
+
error.stack = original + '\n' + stack;
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
} catch (e) {
|
|
2449
|
+
// Frozen errors and custom stack accessors must retain their rejection.
|
|
2450
|
+
}
|
|
2451
|
+
return Promise.reject(error);
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
function dispatchAfterRecovery(config) {
|
|
2456
|
+
return function dispatchRecoveredRequest() {
|
|
2457
|
+
return dispatchRequest(config);
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2329
2461
|
/**
|
|
2330
2462
|
* Create a new instance of Axios
|
|
2331
2463
|
*
|
|
@@ -2356,11 +2488,14 @@
|
|
|
2356
2488
|
}
|
|
2357
2489
|
|
|
2358
2490
|
config = mergeConfig(this.defaults, config);
|
|
2491
|
+
var caller = config.captureCallerStack === true ? captureCallerStack(request) : null;
|
|
2359
2492
|
|
|
2360
|
-
// Set config.method
|
|
2493
|
+
// Set config.method. The merged config is null-prototype, but instance
|
|
2494
|
+
// defaults may be an ordinary object, so the fallback is read as an own
|
|
2495
|
+
// property to keep an inherited value from choosing the request method.
|
|
2361
2496
|
if (config.method) {
|
|
2362
2497
|
config.method = config.method.toLowerCase();
|
|
2363
|
-
} else if (this.defaults.method) {
|
|
2498
|
+
} else if (utils.hasOwnProperty(this.defaults, 'method') && this.defaults.method) {
|
|
2364
2499
|
config.method = this.defaults.method.toLowerCase();
|
|
2365
2500
|
} else {
|
|
2366
2501
|
config.method = 'get';
|
|
@@ -2422,7 +2557,7 @@
|
|
|
2422
2557
|
promise = promise.then(chain.shift(), chain.shift());
|
|
2423
2558
|
}
|
|
2424
2559
|
|
|
2425
|
-
return promise;
|
|
2560
|
+
return attachCallerStack(promise, caller);
|
|
2426
2561
|
}
|
|
2427
2562
|
|
|
2428
2563
|
|
|
@@ -2431,24 +2566,39 @@
|
|
|
2431
2566
|
var onFulfilled = requestInterceptorChain.shift();
|
|
2432
2567
|
var onRejected = requestInterceptorChain.shift();
|
|
2433
2568
|
try {
|
|
2434
|
-
newConfig = onFulfilled(newConfig);
|
|
2569
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
2435
2570
|
} catch (error) {
|
|
2436
|
-
onRejected
|
|
2571
|
+
if (!onRejected) {
|
|
2572
|
+
promise = Promise.reject(error);
|
|
2573
|
+
break;
|
|
2574
|
+
}
|
|
2575
|
+
try {
|
|
2576
|
+
var recovery = onRejected(error);
|
|
2577
|
+
if (recovery && typeof recovery.then === 'function') {
|
|
2578
|
+
promise = Promise.resolve(recovery).then(dispatchAfterRecovery(newConfig));
|
|
2579
|
+
}
|
|
2580
|
+
} catch (rejectedError) {
|
|
2581
|
+
promise = Promise.reject(rejectedError);
|
|
2582
|
+
}
|
|
2437
2583
|
break;
|
|
2438
2584
|
}
|
|
2439
2585
|
}
|
|
2440
2586
|
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2587
|
+
if (!promise) {
|
|
2588
|
+
try {
|
|
2589
|
+
promise = dispatchRequest(newConfig);
|
|
2590
|
+
} catch (error) {
|
|
2591
|
+
// Dispatch errors, including pre-aborted signals, still go through the
|
|
2592
|
+
// response interceptors registered below.
|
|
2593
|
+
promise = Promise.reject(error);
|
|
2594
|
+
}
|
|
2445
2595
|
}
|
|
2446
2596
|
|
|
2447
2597
|
while (responseInterceptorChain.length) {
|
|
2448
2598
|
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
|
2449
2599
|
}
|
|
2450
2600
|
|
|
2451
|
-
return promise;
|
|
2601
|
+
return attachCallerStack(promise, caller);
|
|
2452
2602
|
};
|
|
2453
2603
|
|
|
2454
2604
|
Axios.prototype.getUri = function getUri(config) {
|