axios 0.33.0 → 0.35.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/dist/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // axios v0.33.0 Copyright (c) 2026 Matt Zabriskie
1
+ // axios v0.35.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
- constructor.prototype.constructor = constructor;
419
- props && Object.assign(constructor.prototype, props);
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
  /**
@@ -487,10 +517,75 @@
487
517
  if (!thing) return null;
488
518
  if (isArray(thing)) return thing;
489
519
  var i = thing.length;
490
- if (!isNumber(i)) return null;
520
+ if (typeof i !== 'number' || i < 0 || i > 0xffffffff || Math.floor(i) !== i) return null;
521
+
522
+ // Legacy FileList hosts expose indexed reads without reflecting their keys.
523
+ if (isFileList(thing)) {
524
+ var files = [];
525
+ while (i-- > 0) {
526
+ var file = thing[i];
527
+ if (file === null || isUndefined(file)) return null;
528
+ defineOwnProperty(files, i, file);
529
+ }
530
+ return files;
531
+ }
532
+
533
+ // Count actual indexes, including hidden collection properties, before
534
+ // allocating from the declared length. Box primitives for ES5 object APIs.
535
+ var source = Object(thing);
536
+ var indexes = Object.create(null);
537
+ var count = 0;
538
+ var seen = [];
539
+ var owns = Object.prototype.hasOwnProperty;
540
+
541
+ while (source && count < i) {
542
+ if (seen.indexOf(source) !== -1) return null;
543
+ defineOwnProperty(seen, seen.length, source);
544
+
545
+ if (source === Object.prototype) break;
546
+
547
+ var prototype = Object.getPrototypeOf(source);
548
+ if (prototype === null) {
549
+ var constructorDescriptor = Object.getOwnPropertyDescriptor(source, 'constructor');
550
+ var constructorValue = constructorDescriptor && owns.call(constructorDescriptor, 'value') &&
551
+ constructorDescriptor.value;
552
+ var constructorPrototype = typeof constructorValue === 'function' &&
553
+ Object.getOwnPropertyDescriptor(constructorValue, 'prototype');
554
+
555
+ // Recognize another realm's Object.prototype without excluding
556
+ // application-defined null-prototype parents or invoking accessors.
557
+ if (
558
+ constructorPrototype && owns.call(constructorPrototype, 'value') &&
559
+ constructorPrototype.value === source &&
560
+ Function.prototype.toString.call(constructorValue) === Function.prototype.toString.call(Object)
561
+ ) {
562
+ break;
563
+ }
564
+ }
565
+
566
+ var keys = Object.getOwnPropertyNames(source);
567
+ for (var j = 0; j < keys.length; j++) {
568
+ var key = keys[j];
569
+ var index = +key;
570
+ if (
571
+ index >= 0 &&
572
+ index < i &&
573
+ Math.floor(index) === index &&
574
+ String(index) === key &&
575
+ owns.call(source, key) &&
576
+ !indexes[key]
577
+ ) {
578
+ indexes[key] = true;
579
+ count++;
580
+ }
581
+ }
582
+ source = prototype;
583
+ }
584
+
585
+ if (count !== i) return null;
491
586
  var arr = new Array(i);
492
587
  while (i-- > 0) {
493
- arr[i] = thing[i];
588
+ defineOwnProperty(arr, i, thing[i]);
494
589
  }
495
590
  return arr;
496
591
  }
@@ -560,6 +655,7 @@
560
655
  trim: trim,
561
656
  stripBOM: stripBOM,
562
657
  inherits: inherits,
658
+ defineOwnProperty: defineOwnProperty,
563
659
  toFlatObject: toFlatObject,
564
660
  kindOf: kindOf,
565
661
  kindOfTest: kindOfTest,
@@ -779,6 +875,40 @@
779
875
  return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
780
876
  }
781
877
 
878
+ var UNSAFE_OPTION_KEYS = ['__proto__', 'constructor', 'prototype'];
879
+
880
+ // Materialises the serializer options onto a null-prototype object. Reading the
881
+ // options from a plain object let a polluted Object.prototype supply a visitor,
882
+ // a depth limit, a Blob implementation or key-format flags that the caller never
883
+ // asked for, and also let a polluted key mask an option the caller did set.
884
+ // Only own, defined properties of the caller's options are carried over.
885
+ function toFormDataOptions(source) {
886
+ var options = Object.create(null);
887
+
888
+ options.metaTokens = true;
889
+ options.dots = false;
890
+ options.indexes = false;
891
+
892
+ // eslint-disable-next-line no-eq-null,eqeqeq
893
+ if (source == null) {
894
+ return options;
895
+ }
896
+
897
+ var names = Object.getOwnPropertyNames(source);
898
+
899
+ for (var i = 0; i < names.length; i++) {
900
+ var name = names[i];
901
+
902
+ if (UNSAFE_OPTION_KEYS.indexOf(name) !== -1 || utils.isUndefined(source[name])) {
903
+ continue;
904
+ }
905
+
906
+ options[name] = source[name];
907
+ }
908
+
909
+ return options;
910
+ }
911
+
782
912
  /**
783
913
  * Convert a data object to FormData
784
914
  * @param {Object} obj
@@ -800,14 +930,7 @@
800
930
  formData = formData || new (FormData$1 || FormData)();
801
931
 
802
932
  // eslint-disable-next-line no-param-reassign
803
- options = utils.toFlatObject(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
- });
933
+ options = toFormDataOptions(options);
811
934
 
812
935
  var metaTokens = options.metaTokens;
813
936
  // eslint-disable-next-line no-use-before-define
@@ -854,7 +977,7 @@
854
977
  return;
855
978
  }
856
979
 
857
- stack.push(value);
980
+ utils.defineOwnProperty(stack, stack.length, value);
858
981
 
859
982
  utils.forEach(value, function each(el) {
860
983
  assertValueDepth(el, depth + 1);
@@ -883,8 +1006,8 @@
883
1006
  value = JSON.stringify(value);
884
1007
  } else if (
885
1008
  (utils.isArray(value) && isFlatArray(value)) ||
886
- (utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
887
- )) {
1009
+ ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)))
1010
+ ) {
888
1011
  // eslint-disable-next-line no-param-reassign
889
1012
  key = removeBrackets(key);
890
1013
 
@@ -931,7 +1054,7 @@
931
1054
  throw Error('Circular reference detected in ' + path.join('.'));
932
1055
  }
933
1056
 
934
- stack.push(value);
1057
+ utils.defineOwnProperty(stack, stack.length, value);
935
1058
 
936
1059
  utils.forEach(value, function each(el, key) {
937
1060
  var result = !(utils.isUndefined(el) || el === null) && visitor.call(
@@ -1203,13 +1326,50 @@
1203
1326
  return obj;
1204
1327
  }
1205
1328
 
1329
+ function normalizeArray(value) {
1330
+ if (!utils.isArray(value)) return value;
1331
+
1332
+ var keys = Object.keys(value);
1333
+ if (keys.length !== value.length) return arrayToObject(value);
1334
+
1335
+ for (var i = 0; i < keys.length; i++) {
1336
+ var index = +keys[i];
1337
+ if (
1338
+ index < 0 || index >= value.length ||
1339
+ Math.floor(index) !== index || String(index) !== keys[i]
1340
+ ) {
1341
+ return arrayToObject(value);
1342
+ }
1343
+ }
1344
+
1345
+ return value;
1346
+ }
1347
+
1348
+ function normalizeArrays(obj) {
1349
+ var pending = [obj];
1350
+ function normalizeEntry(target, key) {
1351
+ var value = target[key] = normalizeArray(target[key]);
1352
+ if (utils.isArray(value) || utils.isPlainObject(value)) {
1353
+ pending.push(value);
1354
+ }
1355
+ }
1356
+ while (pending.length) {
1357
+ var target = pending.pop();
1358
+ var keys = Object.keys(target);
1359
+ for (var i = 0; i < keys.length; i++) {
1360
+ normalizeEntry(target, keys[i]);
1361
+ }
1362
+ }
1363
+ return obj;
1364
+ }
1365
+
1206
1366
  function formDataToJSON(formData) {
1207
1367
  function buildPath(path, value, target, index) {
1208
1368
  var name = path[index++];
1209
1369
 
1210
1370
  if (name === '__proto__') return true;
1211
1371
 
1212
- var isNumericKey = Number.isFinite(+name);
1372
+ var isNumericKey = isFinite(+name);
1213
1373
  var isLast = index >= path.length;
1214
1374
  name = !name && utils.isArray(target) ? target.length : name;
1215
1375
 
@@ -1223,7 +1383,7 @@
1223
1383
  return !isNumericKey;
1224
1384
  }
1225
1385
 
1226
- if (!target[name] || !utils.isObject(target[name])) {
1386
+ if (!utils.hasOwnProperty(target, name) || !utils.isObject(target[name])) {
1227
1387
  target[name] = [];
1228
1388
  }
1229
1389
 
@@ -1246,7 +1406,7 @@
1246
1406
  buildPath(path, value, obj, 0);
1247
1407
  });
1248
1408
 
1249
- return obj;
1409
+ return normalizeArrays(obj);
1250
1410
  }
1251
1411
 
1252
1412
  return null;
@@ -1519,6 +1679,23 @@
1519
1679
 
1520
1680
  var CanceledError_1 = CanceledError;
1521
1681
 
1682
+ var fromSignal = function fromSignal(signal, config, request) {
1683
+ var error = new CanceledError_1(null, config, request);
1684
+
1685
+ if (signal) {
1686
+ try {
1687
+ var reason = signal.reason;
1688
+ if (reason !== undefined) {
1689
+ error.reason = reason;
1690
+ }
1691
+ } catch (e) {
1692
+ // A custom signal getter must not prevent cancellation.
1693
+ }
1694
+ }
1695
+
1696
+ return error;
1697
+ };
1698
+
1522
1699
  var parseProtocol = function parseProtocol(url) {
1523
1700
  var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1524
1701
  return match && match[1] || '';
@@ -1772,7 +1949,7 @@
1772
1949
  }
1773
1950
  reject(
1774
1951
  !cancel || cancel.type
1775
- ? new CanceledError_1(null, config, request)
1952
+ ? fromSignal(config.signal, config, request)
1776
1953
  : cancel
1777
1954
  );
1778
1955
  request.abort();
@@ -2036,7 +2213,7 @@
2036
2213
  }
2037
2214
 
2038
2215
  if (config.signal && config.signal.aborted) {
2039
- throw new CanceledError_1();
2216
+ throw fromSignal(config.signal, config);
2040
2217
  }
2041
2218
  }
2042
2219
 
@@ -2049,8 +2226,9 @@
2049
2226
  var dispatchRequest = function dispatchRequest(config) {
2050
2227
  throwIfCancellationRequested(config);
2051
2228
 
2052
- // Ensure headers exist
2053
- config.headers = config.headers || {};
2229
+ // Ensure headers exist. A request interceptor may return a replacement config
2230
+ // that inherits from Object.prototype, so only an own headers value is used.
2231
+ config.headers = (utils.hasOwnProperty(config, 'headers') && config.headers) || {};
2054
2232
 
2055
2233
  // Transform request data
2056
2234
  config.data = transformData.call(
@@ -2122,6 +2300,102 @@
2122
2300
  });
2123
2301
  };
2124
2302
 
2303
+ // Match numeric array reads without scanning unoccupied slots or metadata.
2304
+ function arrayIndexes(array) {
2305
+ var length = array.length;
2306
+ var indexes = Object.create(null);
2307
+ var keys = [];
2308
+ var source = array;
2309
+ var fast = array;
2310
+ while (source) {
2311
+ var names = Object.getOwnPropertyNames(source);
2312
+ for (var i = 0; i < names.length; i++) {
2313
+ var key = names[i];
2314
+ var index = +key;
2315
+ if (index >= 0 && index < length && Math.floor(index) === index &&
2316
+ String(index) === key && !indexes[key]) {
2317
+ indexes[key] = true;
2318
+ keys.push(key);
2319
+ }
2320
+ }
2321
+ source = Object.getPrototypeOf(source);
2322
+ // Detect unusual cyclic prototype chains with constant memory.
2323
+ fast = fast && Object.getPrototypeOf(fast);
2324
+ fast = fast && Object.getPrototypeOf(fast);
2325
+ if (source && source === fast) {
2326
+ throw new AxiosError_1('Circular prototype chain in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
2327
+ }
2328
+ }
2329
+ return keys.sort(function(a, b) { return a - b; });
2330
+ }
2331
+
2332
+ var assertParamsDepth = function assertParamsDepth(params) {
2333
+ if (!utils.isObject(params)) return;
2334
+ var pending = [{ value: params, depth: 0, complete: false }];
2335
+ var ancestors = [];
2336
+ var visited = null;
2337
+ if (typeof WeakMap === 'function') {
2338
+ visited = new WeakMap();
2339
+ } else if (typeof Map === 'function') {
2340
+ visited = new Map();
2341
+ }
2342
+ // Older runtimes can only compare immutable object identities by scanning.
2343
+ // Keep that scan bounded; recently completed subgraphs avoid repeated work,
2344
+ // while evicted shared subgraphs may be visited again.
2345
+ var cacheSize = 128;
2346
+ var visitedValues = [];
2347
+ var visitedDepths = [];
2348
+ var nextCacheIndex = 0;
2349
+ while (pending.length) {
2350
+ var entry = pending.pop();
2351
+ var value = entry.value;
2352
+ var index;
2353
+ if (entry.complete) {
2354
+ ancestors.pop();
2355
+ if (visited) {
2356
+ visited.set(value, entry.depth);
2357
+ } else {
2358
+ index = visitedValues.indexOf(value);
2359
+ if (index === -1) {
2360
+ index = nextCacheIndex;
2361
+ nextCacheIndex = (nextCacheIndex + 1) % cacheSize;
2362
+ }
2363
+ visitedValues[index] = value;
2364
+ visitedDepths[index] = entry.depth;
2365
+ }
2366
+ continue;
2367
+ }
2368
+ // The serializer enumerates any object at its root, then recursively
2369
+ // visits only plain objects and arrays below that root.
2370
+ if (entry.depth === 0 ? !utils.isObject(value) :
2371
+ !utils.isPlainObject(value) && !utils.isArray(value)) {
2372
+ continue;
2373
+ }
2374
+ if (entry.depth > 100) {
2375
+ throw new AxiosError_1('params exceed the maximum depth of 100', AxiosError_1.ERR_BAD_OPTION_VALUE);
2376
+ }
2377
+ // The depth cap bounds this ancestry scan independently of params width.
2378
+ if (ancestors.indexOf(value) !== -1) {
2379
+ throw new AxiosError_1('Circular reference detected in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
2380
+ }
2381
+ if (visited) {
2382
+ if (visited.has(value) && visited.get(value) >= entry.depth) continue;
2383
+ } else {
2384
+ index = visitedValues.indexOf(value);
2385
+ if (index !== -1 && visitedDepths[index] >= entry.depth) continue;
2386
+ }
2387
+ ancestors.push(value);
2388
+ pending.push({ value: value, depth: entry.depth, complete: true });
2389
+ var keys = utils.isArray(value) ? arrayIndexes(value) : Object.keys(value);
2390
+ for (var i = 0; i < keys.length; i++) {
2391
+ var key = keys[i];
2392
+ if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
2393
+ pending.push({ value: value[key], depth: entry.depth + 1, complete: false });
2394
+ }
2395
+ }
2396
+ }
2397
+ };
2398
+
2125
2399
  /**
2126
2400
  * Config-specific merge-function which creates a new config-object
2127
2401
  * by merging two configuration objects together.
@@ -2133,6 +2407,8 @@
2133
2407
  var mergeConfig = function mergeConfig(config1, config2) {
2134
2408
  // eslint-disable-next-line no-param-reassign
2135
2409
  config2 = config2 || {};
2410
+ assertParamsDepth(utils.hasOwnProperty(config1, 'params') ? config1.params : undefined);
2411
+ assertParamsDepth(utils.hasOwnProperty(config2, 'params') ? config2.params : undefined);
2136
2412
  // Use a null-prototype object so a polluted Object.prototype cannot leak
2137
2413
  // values (e.g. transport, adapter) into the returned config via inheritance.
2138
2414
  var config = Object.create(null);
@@ -2183,6 +2459,11 @@
2183
2459
  }
2184
2460
  }
2185
2461
 
2462
+ function defaultToConfig2Reference(prop) {
2463
+ var value = getOwn(config2, prop);
2464
+ return utils.isUndefined(value) ? getOwn(config1, prop) : value;
2465
+ }
2466
+
2186
2467
  // eslint-disable-next-line consistent-return
2187
2468
  function mergeDirectKeys(prop) {
2188
2469
  if (hasOwn(config2, prop)) {
@@ -2218,6 +2499,8 @@
2218
2499
  'httpAgent': defaultToConfig2,
2219
2500
  'httpsAgent': defaultToConfig2,
2220
2501
  'cancelToken': defaultToConfig2,
2502
+ // Signals are live objects; cloning them snapshots getters and reasons.
2503
+ 'signal': defaultToConfig2Reference,
2221
2504
  'socketPath': defaultToConfig2,
2222
2505
  'allowedSocketPaths': defaultToConfig2,
2223
2506
  'responseEncoding': defaultToConfig2,
@@ -2237,7 +2520,7 @@
2237
2520
  };
2238
2521
 
2239
2522
  var data = {
2240
- "version": "0.33.0"
2523
+ "version": "0.35.0"
2241
2524
  };
2242
2525
 
2243
2526
  var VERSION = data.version;
@@ -2326,6 +2609,56 @@
2326
2609
  };
2327
2610
 
2328
2611
  var validators = validator.validators;
2612
+
2613
+ function captureCallerStack(boundary) {
2614
+ var caller = {};
2615
+ try {
2616
+ if (Error.captureStackTrace) {
2617
+ Error.captureStackTrace(caller, boundary);
2618
+ } else {
2619
+ caller = new Error();
2620
+ }
2621
+ } catch (e) {
2622
+ // Stack hooks must not prevent a request from being sent.
2623
+ }
2624
+ return caller;
2625
+ }
2626
+
2627
+ function attachCallerStack(promise, caller) {
2628
+ if (!caller) {
2629
+ return promise;
2630
+ }
2631
+
2632
+ return promise.then(null, function onRequestRejected(error) {
2633
+ try {
2634
+ if (error instanceof Error || Object.prototype.toString.call(error) === '[object Error]') {
2635
+ // Capture at dispatch time, but only format the stack on failure.
2636
+ // Capturing in this callback would lose callers using .then/.catch.
2637
+ var stack = caller.stack;
2638
+ if (typeof stack === 'string') {
2639
+ var newline = stack.indexOf('\n');
2640
+ stack = newline === -1 ? '' : stack.slice(newline + 1);
2641
+ var original = error.stack;
2642
+ if (stack && (original === undefined || original === null || original === '')) {
2643
+ error.stack = stack;
2644
+ } else if (stack && typeof original === 'string' && original.indexOf(stack) === -1) {
2645
+ error.stack = original + '\n' + stack;
2646
+ }
2647
+ }
2648
+ }
2649
+ } catch (e) {
2650
+ // Frozen errors and custom stack accessors must retain their rejection.
2651
+ }
2652
+ return Promise.reject(error);
2653
+ });
2654
+ }
2655
+
2656
+ function dispatchAfterRecovery(config) {
2657
+ return function dispatchRecoveredRequest() {
2658
+ return dispatchRequest(config);
2659
+ };
2660
+ }
2661
+
2329
2662
  /**
2330
2663
  * Create a new instance of Axios
2331
2664
  *
@@ -2355,12 +2688,19 @@
2355
2688
  config = configOrUrl || {};
2356
2689
  }
2357
2690
 
2358
- config = mergeConfig(this.defaults, config);
2691
+ try {
2692
+ config = mergeConfig(this.defaults, config);
2693
+ } catch (error) {
2694
+ return Promise.reject(error);
2695
+ }
2696
+ var caller = config.captureCallerStack === true ? captureCallerStack(request) : null;
2359
2697
 
2360
- // Set config.method
2698
+ // Set config.method. The merged config is null-prototype, but instance
2699
+ // defaults may be an ordinary object, so the fallback is read as an own
2700
+ // property to keep an inherited value from choosing the request method.
2361
2701
  if (config.method) {
2362
2702
  config.method = config.method.toLowerCase();
2363
- } else if (this.defaults.method) {
2703
+ } else if (utils.hasOwnProperty(this.defaults, 'method') && this.defaults.method) {
2364
2704
  config.method = this.defaults.method.toLowerCase();
2365
2705
  } else {
2366
2706
  config.method = 'get';
@@ -2422,7 +2762,7 @@
2422
2762
  promise = promise.then(chain.shift(), chain.shift());
2423
2763
  }
2424
2764
 
2425
- return promise;
2765
+ return attachCallerStack(promise, caller);
2426
2766
  }
2427
2767
 
2428
2768
 
@@ -2431,24 +2771,39 @@
2431
2771
  var onFulfilled = requestInterceptorChain.shift();
2432
2772
  var onRejected = requestInterceptorChain.shift();
2433
2773
  try {
2434
- newConfig = onFulfilled(newConfig);
2774
+ newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
2435
2775
  } catch (error) {
2436
- onRejected(error);
2776
+ if (!onRejected) {
2777
+ promise = Promise.reject(error);
2778
+ break;
2779
+ }
2780
+ try {
2781
+ var recovery = onRejected(error);
2782
+ if (recovery && typeof recovery.then === 'function') {
2783
+ promise = Promise.resolve(recovery).then(dispatchAfterRecovery(newConfig));
2784
+ }
2785
+ } catch (rejectedError) {
2786
+ promise = Promise.reject(rejectedError);
2787
+ }
2437
2788
  break;
2438
2789
  }
2439
2790
  }
2440
2791
 
2441
- try {
2442
- promise = dispatchRequest(newConfig);
2443
- } catch (error) {
2444
- return Promise.reject(error);
2792
+ if (!promise) {
2793
+ try {
2794
+ promise = dispatchRequest(newConfig);
2795
+ } catch (error) {
2796
+ // Dispatch errors, including pre-aborted signals, still go through the
2797
+ // response interceptors registered below.
2798
+ promise = Promise.reject(error);
2799
+ }
2445
2800
  }
2446
2801
 
2447
2802
  while (responseInterceptorChain.length) {
2448
2803
  promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
2449
2804
  }
2450
2805
 
2451
- return promise;
2806
+ return attachCallerStack(promise, caller);
2452
2807
  };
2453
2808
 
2454
2809
  Axios.prototype.getUri = function getUri(config) {
@@ -2463,11 +2818,16 @@
2463
2818
  Axios.prototype[method] = function(url, config) {
2464
2819
  var requestConfig = config || {};
2465
2820
 
2466
- return this.request(mergeConfig(requestConfig, {
2467
- method: method,
2468
- url: url,
2469
- data: utils.hasOwnProperty(requestConfig, 'data') ? requestConfig.data : undefined
2470
- }));
2821
+ try {
2822
+ requestConfig = mergeConfig(requestConfig, {
2823
+ method: method,
2824
+ url: url,
2825
+ data: utils.hasOwnProperty(requestConfig, 'data') ? requestConfig.data : undefined
2826
+ });
2827
+ } catch (error) {
2828
+ return Promise.reject(error);
2829
+ }
2830
+ return this.request(requestConfig);
2471
2831
  };
2472
2832
  });
2473
2833
 
@@ -2476,14 +2836,20 @@
2476
2836
 
2477
2837
  function generateHTTPMethod(isForm) {
2478
2838
  return function httpMethod(url, data, config) {
2479
- return this.request(mergeConfig(config || {}, {
2480
- method: method,
2481
- headers: isForm ? {
2482
- 'Content-Type': 'multipart/form-data'
2483
- } : {},
2484
- url: url,
2485
- data: data
2486
- }));
2839
+ var requestConfig;
2840
+ try {
2841
+ requestConfig = mergeConfig(config || {}, {
2842
+ method: method,
2843
+ headers: isForm ? {
2844
+ 'Content-Type': 'multipart/form-data'
2845
+ } : {},
2846
+ url: url,
2847
+ data: data
2848
+ });
2849
+ } catch (error) {
2850
+ return Promise.reject(error);
2851
+ }
2852
+ return this.request(requestConfig);
2487
2853
  };
2488
2854
  }
2489
2855