@vercel/client 17.2.12 → 17.2.14
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.
|
@@ -3,5 +3,6 @@ interface DeploymentStatus {
|
|
|
3
3
|
type: DeploymentEventType;
|
|
4
4
|
payload: Deployment | DeploymentBuild[];
|
|
5
5
|
}
|
|
6
|
+
export declare function parseRetryAfterMs(response: any): number | null;
|
|
6
7
|
export declare function checkDeploymentStatus(deployment: Deployment, clientOptions: VercelClientOptions): AsyncIterableIterator<DeploymentStatus>;
|
|
7
8
|
export {};
|
|
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var check_deployment_status_exports = {};
|
|
30
30
|
__export(check_deployment_status_exports, {
|
|
31
|
-
checkDeploymentStatus: () => checkDeploymentStatus
|
|
31
|
+
checkDeploymentStatus: () => checkDeploymentStatus,
|
|
32
|
+
parseRetryAfterMs: () => parseRetryAfterMs
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(check_deployment_status_exports);
|
|
34
35
|
var import_sleep_promise = __toESM(require("sleep-promise"));
|
|
@@ -36,6 +37,35 @@ var import_utils = require("./utils");
|
|
|
36
37
|
var import_get_polling_delay = require("./utils/get-polling-delay");
|
|
37
38
|
var import_ready_state = require("./utils/ready-state");
|
|
38
39
|
var import_utils2 = require("./utils");
|
|
40
|
+
const RETRY_COUNT = 3;
|
|
41
|
+
const RETRY_DELAY_MAX_MS = 6e4;
|
|
42
|
+
const RETRY_DELAY_MIN_MS = 5e3;
|
|
43
|
+
const RETRY_DELAY_DEFAULT_MS = 5e3;
|
|
44
|
+
function parseRetryAfterMs(response) {
|
|
45
|
+
if (response.status === 429 || response.status === 503) {
|
|
46
|
+
let header = response.headers.get("Retry-After");
|
|
47
|
+
if (header == null) {
|
|
48
|
+
return RETRY_DELAY_DEFAULT_MS;
|
|
49
|
+
}
|
|
50
|
+
let retryAfterMs = Number(header) * 1e3;
|
|
51
|
+
if (Number.isNaN(retryAfterMs)) {
|
|
52
|
+
let retryAfterDateMs = Date.parse(header);
|
|
53
|
+
if (Number.isNaN(retryAfterDateMs)) {
|
|
54
|
+
retryAfterMs = RETRY_DELAY_DEFAULT_MS;
|
|
55
|
+
} else {
|
|
56
|
+
retryAfterMs = retryAfterDateMs - Date.now();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return Math.min(
|
|
60
|
+
RETRY_DELAY_MAX_MS,
|
|
61
|
+
Math.max(RETRY_DELAY_MIN_MS, retryAfterMs)
|
|
62
|
+
);
|
|
63
|
+
} else if (response.status >= 500 && response.status <= 599) {
|
|
64
|
+
return RETRY_DELAY_DEFAULT_MS;
|
|
65
|
+
} else {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
39
69
|
async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
40
70
|
const { token, teamId, apiUrl, userAgent } = clientOptions;
|
|
41
71
|
const debug = (0, import_utils2.createDebug)(clientOptions.debug);
|
|
@@ -51,12 +81,29 @@ async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
|
51
81
|
const finishedEvents = /* @__PURE__ */ new Set();
|
|
52
82
|
const startTime = Date.now();
|
|
53
83
|
while (true) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
84
|
+
let deploymentResponse;
|
|
85
|
+
let retriesLeft = RETRY_COUNT;
|
|
86
|
+
while (true) {
|
|
87
|
+
deploymentResponse = await (0, import_utils.fetch)(
|
|
88
|
+
`${apiDeployments}/${deployment.id || deployment.deploymentId}${teamId ? `?teamId=${teamId}` : ""}`,
|
|
89
|
+
token,
|
|
90
|
+
{ apiUrl, userAgent, agent: clientOptions.agent }
|
|
91
|
+
);
|
|
92
|
+
retriesLeft--;
|
|
93
|
+
if (retriesLeft == 0) {
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
const retryAfterMs = parseRetryAfterMs(deploymentResponse);
|
|
97
|
+
if (retryAfterMs != null) {
|
|
98
|
+
debug(
|
|
99
|
+
`Received a transient error or rate limit (HTTP ${deploymentResponse.status}) while querying deployment status, retrying after ${retryAfterMs}ms`
|
|
100
|
+
);
|
|
101
|
+
await (0, import_sleep_promise.default)(retryAfterMs);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
const deploymentUpdate = await deploymentResponse.json();
|
|
60
107
|
if (deploymentUpdate.error) {
|
|
61
108
|
debug("Deployment status check has errorred");
|
|
62
109
|
return yield { type: "error", payload: deploymentUpdate.error };
|
|
@@ -130,5 +177,6 @@ async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
|
130
177
|
}
|
|
131
178
|
// Annotate the CommonJS export names for ESM import in node:
|
|
132
179
|
0 && (module.exports = {
|
|
133
|
-
checkDeploymentStatus
|
|
180
|
+
checkDeploymentStatus,
|
|
181
|
+
parseRetryAfterMs
|
|
134
182
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "17.2.
|
|
3
|
+
"version": "17.2.14",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -31,10 +31,7 @@
|
|
|
31
31
|
"vitest": "2.0.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@vercel/build-utils": "13.2.1",
|
|
35
|
-
"@vercel/error-utils": "2.0.3",
|
|
36
34
|
"@vercel/microfrontends": "1.2.2",
|
|
37
|
-
"@vercel/routing-utils": "5.3.0",
|
|
38
35
|
"async-retry": "1.2.3",
|
|
39
36
|
"async-sema": "3.0.0",
|
|
40
37
|
"fs-extra": "8.0.1",
|
|
@@ -44,7 +41,10 @@
|
|
|
44
41
|
"node-fetch": "2.6.7",
|
|
45
42
|
"querystring": "^0.2.0",
|
|
46
43
|
"sleep-promise": "8.0.1",
|
|
47
|
-
"tar-fs": "1.16.3"
|
|
44
|
+
"tar-fs": "1.16.3",
|
|
45
|
+
"@vercel/build-utils": "13.2.3",
|
|
46
|
+
"@vercel/routing-utils": "5.3.0",
|
|
47
|
+
"@vercel/error-utils": "2.0.3"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "node ../../utils/build.mjs",
|