@vercel/client 18.8.0 → 18.8.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.
- package/dist/check-deployment-status.js +31 -14
- package/dist/continue.js +21 -2
- package/dist/upload.js +9 -17
- package/dist/utils/index.js +17 -5
- package/dist/utils/network-error.d.ts +2 -0
- package/dist/utils/network-error.js +81 -0
- package/package.json +3 -3
|
@@ -33,6 +33,8 @@ __export(check_deployment_status_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(check_deployment_status_exports);
|
|
35
35
|
var import_sleep_promise = __toESM(require("sleep-promise"));
|
|
36
|
+
var import_errors = require("./errors");
|
|
37
|
+
var import_network_error = require("./utils/network-error");
|
|
36
38
|
var import_utils = require("./utils");
|
|
37
39
|
var import_get_polling_delay = require("./utils/get-polling-delay");
|
|
38
40
|
var import_ready_state = require("./utils/ready-state");
|
|
@@ -137,6 +139,7 @@ async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
|
137
139
|
return yield { type: "alias-assigned", payload: deploymentState };
|
|
138
140
|
}
|
|
139
141
|
let deploymentResponse;
|
|
142
|
+
let deploymentUpdate;
|
|
140
143
|
let retriesLeft = RETRY_COUNT;
|
|
141
144
|
while (true) {
|
|
142
145
|
try {
|
|
@@ -148,8 +151,12 @@ async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
|
148
151
|
userAgent,
|
|
149
152
|
dispatcher: clientOptions.dispatcher,
|
|
150
153
|
signal: aliasAssignedSignal
|
|
151
|
-
}
|
|
154
|
+
},
|
|
155
|
+
clientOptions.debug
|
|
152
156
|
);
|
|
157
|
+
if (parseRetryAfterMs(deploymentResponse) == null || retriesLeft === 1) {
|
|
158
|
+
deploymentUpdate = await deploymentResponse.json();
|
|
159
|
+
}
|
|
153
160
|
} catch (error) {
|
|
154
161
|
if (getAliasAssignedEvent(aliasAssignedSignal, deploymentId)) {
|
|
155
162
|
continue polling;
|
|
@@ -158,7 +165,29 @@ async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
|
158
165
|
aliasAssignedSignal = void 0;
|
|
159
166
|
continue polling;
|
|
160
167
|
}
|
|
161
|
-
|
|
168
|
+
if (!(0, import_network_error.isRetryableNetworkError)(error))
|
|
169
|
+
throw error;
|
|
170
|
+
retriesLeft--;
|
|
171
|
+
debug(
|
|
172
|
+
`Deployment status request failed (${retriesLeft} attempts remaining): ${(0, import_network_error.formatNetworkError)(error)}`
|
|
173
|
+
);
|
|
174
|
+
if (retriesLeft === 0) {
|
|
175
|
+
throw Object.assign(
|
|
176
|
+
new import_errors.DeploymentError({
|
|
177
|
+
code: "deployment_status_unavailable",
|
|
178
|
+
message: `Could not confirm the status of deployment ${deploymentId}. The deployment may still complete. Run 'vercel inspect ${deploymentId}' to check its status.`
|
|
179
|
+
}),
|
|
180
|
+
{ cause: error }
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
await sleepUntilAliasAssigned(
|
|
184
|
+
RETRY_DELAY_DEFAULT_MS,
|
|
185
|
+
aliasAssignedSignal,
|
|
186
|
+
deploymentId
|
|
187
|
+
);
|
|
188
|
+
if (getAliasAssignedEvent(aliasAssignedSignal, deploymentId))
|
|
189
|
+
continue polling;
|
|
190
|
+
continue;
|
|
162
191
|
}
|
|
163
192
|
if (getAliasAssignedEvent(aliasAssignedSignal, deploymentId)) {
|
|
164
193
|
continue polling;
|
|
@@ -185,18 +214,6 @@ async function* checkDeploymentStatus(deployment, clientOptions) {
|
|
|
185
214
|
}
|
|
186
215
|
break;
|
|
187
216
|
}
|
|
188
|
-
let deploymentUpdate;
|
|
189
|
-
try {
|
|
190
|
-
deploymentUpdate = await deploymentResponse.json();
|
|
191
|
-
} catch (error) {
|
|
192
|
-
if (getAliasAssignedEvent(aliasAssignedSignal, deploymentId))
|
|
193
|
-
continue;
|
|
194
|
-
if (aliasAssignedSignal?.aborted) {
|
|
195
|
-
aliasAssignedSignal = void 0;
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
throw error;
|
|
199
|
-
}
|
|
200
217
|
if (getAliasAssignedEvent(aliasAssignedSignal, deploymentId))
|
|
201
218
|
continue;
|
|
202
219
|
if (deploymentUpdate.error) {
|
package/dist/continue.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(continue_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(continue_exports);
|
|
34
34
|
var import_path = require("path");
|
|
35
35
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
36
|
+
var import_network_error = require("./utils/network-error");
|
|
36
37
|
var import_check_deployment_status = require("./check-deployment-status");
|
|
37
38
|
var import_utils = require("./utils");
|
|
38
39
|
var import_hashes = require("./utils/hashes");
|
|
@@ -175,6 +176,21 @@ async function* continueDeployment(options) {
|
|
|
175
176
|
});
|
|
176
177
|
}
|
|
177
178
|
async function postContinue(options) {
|
|
179
|
+
try {
|
|
180
|
+
return await postContinueOnce(options);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (!(0, import_network_error.isRetryableNetworkError)(error))
|
|
183
|
+
throw error;
|
|
184
|
+
throw Object.assign(
|
|
185
|
+
new import_errors.DeploymentError({
|
|
186
|
+
code: "deployment_continue_unavailable",
|
|
187
|
+
message: `Could not confirm whether deployment ${options.deploymentId} was resumed. Run 'vercel inspect ${options.deploymentId}' to check its status before retrying.`
|
|
188
|
+
}),
|
|
189
|
+
{ cause: error }
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async function postContinueOnce(options) {
|
|
178
194
|
const debug = (0, import_utils.createDebug)(options.debug);
|
|
179
195
|
debug(`Calling continue deployment endpoint for ${options.deploymentId}`);
|
|
180
196
|
const response = await (0, import_utils.fetchApi)(
|
|
@@ -196,12 +212,15 @@ async function postContinue(options) {
|
|
|
196
212
|
apiUrl: options.apiUrl,
|
|
197
213
|
userAgent: options.userAgent,
|
|
198
214
|
dispatcher: options.dispatcher
|
|
199
|
-
}
|
|
215
|
+
},
|
|
216
|
+
options.debug
|
|
200
217
|
);
|
|
201
218
|
let result;
|
|
202
219
|
try {
|
|
203
220
|
result = await response.json();
|
|
204
|
-
} catch {
|
|
221
|
+
} catch (error) {
|
|
222
|
+
if ((0, import_network_error.isRetryableNetworkError)(error))
|
|
223
|
+
throw error;
|
|
205
224
|
return {
|
|
206
225
|
type: "error",
|
|
207
226
|
error: new Error("Invalid JSON response from continue endpoint")
|
package/dist/upload.js
CHANGED
|
@@ -40,19 +40,8 @@ var import_async_retry = __toESM(require("async-retry"));
|
|
|
40
40
|
var import_async_sema = require("async-sema");
|
|
41
41
|
var import_utils = require("./utils");
|
|
42
42
|
var import_errors = require("./errors");
|
|
43
|
+
var import_network_error = require("./utils/network-error");
|
|
43
44
|
var import_deploy = require("./deploy");
|
|
44
|
-
const isClientNetworkError = (err) => {
|
|
45
|
-
if (!(err instanceof Error)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
if (err.message) {
|
|
49
|
-
const matches = err.message.includes("ETIMEDOUT") || err.message.includes("ECONNREFUSED") || err.message.includes("ENOTFOUND") || err.message.includes("ECONNRESET") || err.message.includes("EAI_FAIL") || err.message.includes("socket hang up") || err.message.includes("network socket disconnected");
|
|
50
|
-
if (matches) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return isClientNetworkError(err.cause);
|
|
55
|
-
};
|
|
56
45
|
async function* upload(files, clientOptions, deploymentOptions) {
|
|
57
46
|
const debug = (0, import_utils.createDebug)(clientOptions.debug);
|
|
58
47
|
if (!files && !clientOptions.token && !clientOptions.teamId) {
|
|
@@ -175,6 +164,7 @@ async function* uploadFiles(options) {
|
|
|
175
164
|
}
|
|
176
165
|
let err;
|
|
177
166
|
let result;
|
|
167
|
+
let retryableServerError = false;
|
|
178
168
|
const abortController = new AbortController();
|
|
179
169
|
abortControllers.add(abortController);
|
|
180
170
|
try {
|
|
@@ -213,22 +203,24 @@ async function* uploadFiles(options) {
|
|
|
213
203
|
const { error } = await res.json();
|
|
214
204
|
err = new import_errors.DeploymentError(error);
|
|
215
205
|
} else {
|
|
206
|
+
retryableServerError = res.status >= 500 && res.status <= 599;
|
|
216
207
|
debug(`A server error occurred in upload request. Retrying...`);
|
|
217
208
|
const { error } = await res.json();
|
|
218
209
|
throw new import_errors.DeploymentError(error);
|
|
219
210
|
}
|
|
220
211
|
} catch (e) {
|
|
221
|
-
debug(`
|
|
222
|
-
${e}`);
|
|
212
|
+
debug(`Upload failed: ${(0, import_network_error.formatNetworkError)(e)}`);
|
|
223
213
|
err = e instanceof Error ? e : new Error(String(e));
|
|
224
214
|
}
|
|
225
215
|
semaphore.release();
|
|
226
216
|
if (err) {
|
|
227
|
-
if (
|
|
228
|
-
debug(
|
|
217
|
+
if (retryableServerError || (0, import_network_error.isRetryableNetworkError)(err)) {
|
|
218
|
+
debug(
|
|
219
|
+
`Transient upload failure, retrying: ${(0, import_network_error.formatNetworkError)(err)}`
|
|
220
|
+
);
|
|
229
221
|
throw err;
|
|
230
222
|
} else {
|
|
231
|
-
debug(
|
|
223
|
+
debug(`Upload failed without retry: ${(0, import_network_error.formatNetworkError)(err)}`);
|
|
232
224
|
if (!aborted) {
|
|
233
225
|
aborted = true;
|
|
234
226
|
abortControllers.forEach((controller) => controller.abort());
|
package/dist/utils/index.js
CHANGED
|
@@ -40,6 +40,7 @@ __export(utils_exports, {
|
|
|
40
40
|
shouldInlineStaticFiles: () => shouldInlineStaticFiles
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(utils_exports);
|
|
43
|
+
var import_network_error = require("./network-error");
|
|
43
44
|
var import_path = require("path");
|
|
44
45
|
var import_stream = require("stream");
|
|
45
46
|
var import_url = require("url");
|
|
@@ -443,9 +444,9 @@ const fetchApi = async (url, token, opts = {}, debugEnabled) => {
|
|
|
443
444
|
url += `${url.includes("?") ? "&" : "?"}teamId=${VERCEL_TEAM_ID}`;
|
|
444
445
|
}
|
|
445
446
|
if (opts.teamId) {
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
url =
|
|
447
|
+
const parsedUrl2 = new import_url.URL(url);
|
|
448
|
+
parsedUrl2.searchParams.set("teamId", opts.teamId);
|
|
449
|
+
url = parsedUrl2.toString();
|
|
449
450
|
delete opts.teamId;
|
|
450
451
|
}
|
|
451
452
|
const userAgent = opts.userAgent || `client-v${import_pkg.pkgVersion}`;
|
|
@@ -459,12 +460,23 @@ const fetchApi = async (url, token, opts = {}, debugEnabled) => {
|
|
|
459
460
|
if (opts.body instanceof import_stream.Readable) {
|
|
460
461
|
opts.duplex = "half";
|
|
461
462
|
}
|
|
462
|
-
|
|
463
|
+
const parsedUrl = new import_url.URL(url);
|
|
464
|
+
const request = `${opts.method || "GET"} ${parsedUrl.origin}${parsedUrl.pathname}`;
|
|
465
|
+
debug(request);
|
|
463
466
|
time = Date.now();
|
|
464
467
|
try {
|
|
465
468
|
const res = await fetch(url, opts);
|
|
466
|
-
|
|
469
|
+
const requestId = res.headers.get("x-vercel-id");
|
|
470
|
+
const id = requestId && /^[a-zA-Z0-9:_.-]{1,200}$/.test(requestId) ? ` requestId=${requestId}` : "";
|
|
471
|
+
debug(
|
|
472
|
+
`DONE in ${Date.now() - time}ms: ${request} status=${res.status}${id}`
|
|
473
|
+
);
|
|
467
474
|
return res;
|
|
475
|
+
} catch (error) {
|
|
476
|
+
debug(
|
|
477
|
+
`FAILED in ${Date.now() - time}ms: ${request} ${(0, import_network_error.formatNetworkError)(error)}`
|
|
478
|
+
);
|
|
479
|
+
throw error;
|
|
468
480
|
} finally {
|
|
469
481
|
semaphore.release();
|
|
470
482
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var network_error_exports = {};
|
|
20
|
+
__export(network_error_exports, {
|
|
21
|
+
formatNetworkError: () => formatNetworkError,
|
|
22
|
+
isRetryableNetworkError: () => isRetryableNetworkError
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(network_error_exports);
|
|
25
|
+
const retryableCodes = /* @__PURE__ */ new Set([
|
|
26
|
+
"ETIMEDOUT",
|
|
27
|
+
"ECONNREFUSED",
|
|
28
|
+
"ENOTFOUND",
|
|
29
|
+
"ECONNRESET",
|
|
30
|
+
"EAI_FAIL",
|
|
31
|
+
"EAI_AGAIN",
|
|
32
|
+
"EPIPE",
|
|
33
|
+
"ENETUNREACH",
|
|
34
|
+
"EHOSTUNREACH",
|
|
35
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
36
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
37
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
38
|
+
"UND_ERR_SOCKET"
|
|
39
|
+
]);
|
|
40
|
+
function isRetryableNetworkError(error, depth = 0) {
|
|
41
|
+
if (!(error instanceof Error) || depth > 5 || error.name === "AbortError") {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const err = error;
|
|
45
|
+
if (err.code)
|
|
46
|
+
return retryableCodes.has(err.code);
|
|
47
|
+
if (Array.isArray(err.errors) && err.errors.length > 0) {
|
|
48
|
+
return err.errors.every((child) => isRetryableNetworkError(child, depth + 1));
|
|
49
|
+
}
|
|
50
|
+
if (err.cause)
|
|
51
|
+
return isRetryableNetworkError(err.cause, depth + 1);
|
|
52
|
+
return /ETIMEDOUT|ECONNREFUSED|ENOTFOUND|ECONNRESET|EAI_FAIL|socket hang up|network socket disconnected/.test(
|
|
53
|
+
err.message
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
function formatNetworkError(error, depth = 0) {
|
|
57
|
+
if (!(error instanceof Error))
|
|
58
|
+
return "Unknown error";
|
|
59
|
+
if (depth > 5)
|
|
60
|
+
return "[truncated]";
|
|
61
|
+
const err = error;
|
|
62
|
+
const fields = [];
|
|
63
|
+
for (const value of [err.name, err.code]) {
|
|
64
|
+
if (typeof value === "string" && /^[a-zA-Z_][a-zA-Z0-9_]{0,63}$/.test(value)) {
|
|
65
|
+
fields.push(value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (Array.isArray(err.errors)) {
|
|
69
|
+
fields.push(
|
|
70
|
+
`[${err.errors.slice(0, 5).map((child) => formatNetworkError(child, depth + 1)).join(", ")}]`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (err.cause)
|
|
74
|
+
fields.push(`cause=(${formatNetworkError(err.cause, depth + 1)})`);
|
|
75
|
+
return fields.join(" ") || "Error";
|
|
76
|
+
}
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
formatNetworkError,
|
|
80
|
+
isRetryableNetworkError
|
|
81
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "18.8.
|
|
3
|
+
"version": "18.8.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"querystring": "^0.2.0",
|
|
38
38
|
"sleep-promise": "8.0.1",
|
|
39
39
|
"tar-fs": "1.16.3",
|
|
40
|
+
"@vercel/build-utils": "14.20.0",
|
|
40
41
|
"@vercel/error-utils": "2.2.1",
|
|
41
|
-
"@vercel/routing-utils": "6.6.0"
|
|
42
|
-
"@vercel/build-utils": "14.19.0"
|
|
42
|
+
"@vercel/routing-utils": "6.6.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "node ../../utils/build.mjs",
|