vigor-fetch 4.0.3 → 4.0.4
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/index.d.ts +4 -0
- package/dist/index.js +13 -5
- package/dist/index.mjs +13 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5218,9 +5218,11 @@ declare const VigorRetryErrorMessageFuncs: {
|
|
|
5218
5218
|
}) => string;
|
|
5219
5219
|
readonly RETRY_EXHAUSTED: ({ maxAttempts }: {
|
|
5220
5220
|
maxAttempts: number;
|
|
5221
|
+
error: unknown;
|
|
5221
5222
|
}) => string;
|
|
5222
5223
|
readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
|
|
5223
5224
|
maxAttempts: number;
|
|
5225
|
+
error: unknown;
|
|
5224
5226
|
}) => string;
|
|
5225
5227
|
readonly TIMED_OUT: ({ limit }: {
|
|
5226
5228
|
limit: number;
|
|
@@ -5253,6 +5255,7 @@ declare const VigorParseErrorMessageFuncs: {
|
|
|
5253
5255
|
}) => string;
|
|
5254
5256
|
readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
|
|
5255
5257
|
maxAttempts: number;
|
|
5258
|
+
error: unknown;
|
|
5256
5259
|
}) => string;
|
|
5257
5260
|
};
|
|
5258
5261
|
type VigorParseErrorCodes = keyof typeof VigorParseErrorMessageFuncs;
|
|
@@ -5286,6 +5289,7 @@ declare const VigorFetchErrorMessageFuncs: {
|
|
|
5286
5289
|
}) => string;
|
|
5287
5290
|
readonly RESTART_EXHAUSTED: ({ maxAttempts }: {
|
|
5288
5291
|
maxAttempts: number;
|
|
5292
|
+
error: unknown;
|
|
5289
5293
|
}) => string;
|
|
5290
5294
|
};
|
|
5291
5295
|
type VigorFetchErrorCodes = keyof typeof VigorFetchErrorMessageFuncs;
|
package/dist/index.js
CHANGED
|
@@ -1003,8 +1003,10 @@ class VigorRetry extends VigorStatus {
|
|
|
1003
1003
|
}
|
|
1004
1004
|
throw new VigorRetryError("RETRY_EXHAUSTED", {
|
|
1005
1005
|
method: "request",
|
|
1006
|
+
cause: ctx.error,
|
|
1006
1007
|
data: {
|
|
1007
|
-
maxAttempts: ctx.policy.settings.maxAttempts
|
|
1008
|
+
maxAttempts: ctx.policy.settings.maxAttempts,
|
|
1009
|
+
error: ctx.error
|
|
1008
1010
|
}
|
|
1009
1011
|
});
|
|
1010
1012
|
}
|
|
@@ -1035,8 +1037,10 @@ class VigorRetry extends VigorStatus {
|
|
|
1035
1037
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1036
1038
|
throw new VigorRetryError("RESTART_EXHAUSTED", {
|
|
1037
1039
|
method: "request",
|
|
1040
|
+
cause: ctx.error,
|
|
1038
1041
|
data: {
|
|
1039
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1042
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1043
|
+
error: ctx.error
|
|
1040
1044
|
}
|
|
1041
1045
|
});
|
|
1042
1046
|
return await this.requestRuntime(restartAttempt + 1);
|
|
@@ -1426,8 +1430,10 @@ class VigorParse extends VigorStatus {
|
|
|
1426
1430
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1427
1431
|
throw new VigorParseError("RESTART_EXHAUSTED", {
|
|
1428
1432
|
method: "request",
|
|
1433
|
+
cause: ctx.error,
|
|
1429
1434
|
data: {
|
|
1430
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1435
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1436
|
+
error: ctx.error
|
|
1431
1437
|
}
|
|
1432
1438
|
});
|
|
1433
1439
|
return await this.requestRuntime(restartAttempt + 1);
|
|
@@ -1726,7 +1732,7 @@ class VigorFetch extends VigorStatus {
|
|
|
1726
1732
|
});
|
|
1727
1733
|
ctx.href = this._buildUrl(ctx.policy.origin, ctx.policy.path, ctx.policy.query, ctx.policy.hash);
|
|
1728
1734
|
const hasBody = !isVigorEmpty(ctx.policy.body) && ctx.policy.body !== undefined;
|
|
1729
|
-
const method = ctx.policy.method
|
|
1735
|
+
const method = isVigorEmpty(ctx.policy.method) ? (hasBody ? "POST" : "GET") : ctx.policy.method;
|
|
1730
1736
|
let options = {
|
|
1731
1737
|
...ctx.policy.extra,
|
|
1732
1738
|
method: method,
|
|
@@ -1863,8 +1869,10 @@ class VigorFetch extends VigorStatus {
|
|
|
1863
1869
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1864
1870
|
throw new VigorFetchError("RESTART_EXHAUSTED", {
|
|
1865
1871
|
method: "request",
|
|
1872
|
+
cause: ctx.error,
|
|
1866
1873
|
data: {
|
|
1867
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1874
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1875
|
+
error: ctx.error
|
|
1868
1876
|
}
|
|
1869
1877
|
});
|
|
1870
1878
|
return await this.requestRuntime(restartAttempt + 1);
|
package/dist/index.mjs
CHANGED
|
@@ -999,8 +999,10 @@ class VigorRetry extends VigorStatus {
|
|
|
999
999
|
}
|
|
1000
1000
|
throw new VigorRetryError("RETRY_EXHAUSTED", {
|
|
1001
1001
|
method: "request",
|
|
1002
|
+
cause: ctx.error,
|
|
1002
1003
|
data: {
|
|
1003
|
-
maxAttempts: ctx.policy.settings.maxAttempts
|
|
1004
|
+
maxAttempts: ctx.policy.settings.maxAttempts,
|
|
1005
|
+
error: ctx.error
|
|
1004
1006
|
}
|
|
1005
1007
|
});
|
|
1006
1008
|
}
|
|
@@ -1031,8 +1033,10 @@ class VigorRetry extends VigorStatus {
|
|
|
1031
1033
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1032
1034
|
throw new VigorRetryError("RESTART_EXHAUSTED", {
|
|
1033
1035
|
method: "request",
|
|
1036
|
+
cause: ctx.error,
|
|
1034
1037
|
data: {
|
|
1035
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1038
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1039
|
+
error: ctx.error
|
|
1036
1040
|
}
|
|
1037
1041
|
});
|
|
1038
1042
|
return await this.requestRuntime(restartAttempt + 1);
|
|
@@ -1422,8 +1426,10 @@ class VigorParse extends VigorStatus {
|
|
|
1422
1426
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1423
1427
|
throw new VigorParseError("RESTART_EXHAUSTED", {
|
|
1424
1428
|
method: "request",
|
|
1429
|
+
cause: ctx.error,
|
|
1425
1430
|
data: {
|
|
1426
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1431
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1432
|
+
error: ctx.error
|
|
1427
1433
|
}
|
|
1428
1434
|
});
|
|
1429
1435
|
return await this.requestRuntime(restartAttempt + 1);
|
|
@@ -1722,7 +1728,7 @@ class VigorFetch extends VigorStatus {
|
|
|
1722
1728
|
});
|
|
1723
1729
|
ctx.href = this._buildUrl(ctx.policy.origin, ctx.policy.path, ctx.policy.query, ctx.policy.hash);
|
|
1724
1730
|
const hasBody = !isVigorEmpty(ctx.policy.body) && ctx.policy.body !== undefined;
|
|
1725
|
-
const method = ctx.policy.method
|
|
1731
|
+
const method = isVigorEmpty(ctx.policy.method) ? (hasBody ? "POST" : "GET") : ctx.policy.method;
|
|
1726
1732
|
let options = {
|
|
1727
1733
|
...ctx.policy.extra,
|
|
1728
1734
|
method: method,
|
|
@@ -1859,8 +1865,10 @@ class VigorFetch extends VigorStatus {
|
|
|
1859
1865
|
if (restartAttempt + 1 > ctx.policy.settings.maxRestarts)
|
|
1860
1866
|
throw new VigorFetchError("RESTART_EXHAUSTED", {
|
|
1861
1867
|
method: "request",
|
|
1868
|
+
cause: ctx.error,
|
|
1862
1869
|
data: {
|
|
1863
|
-
maxAttempts: ctx.policy.settings.maxRestarts
|
|
1870
|
+
maxAttempts: ctx.policy.settings.maxRestarts,
|
|
1871
|
+
error: ctx.error
|
|
1864
1872
|
}
|
|
1865
1873
|
});
|
|
1866
1874
|
return await this.requestRuntime(restartAttempt + 1);
|