@vercel/client 13.4.18 → 13.4.20
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/errors.d.ts +2 -0
- package/dist/errors.js +1 -0
- package/dist/upload.js +14 -7
- package/package.json +6 -4
package/dist/errors.d.ts
CHANGED
package/dist/errors.js
CHANGED
package/dist/upload.js
CHANGED
|
@@ -34,7 +34,7 @@ module.exports = __toCommonJS(upload_exports);
|
|
|
34
34
|
var import_http = __toESM(require("http"));
|
|
35
35
|
var import_https = __toESM(require("https"));
|
|
36
36
|
var import_stream = require("stream");
|
|
37
|
-
var import_node_events =
|
|
37
|
+
var import_node_events = require("node:events");
|
|
38
38
|
var import_async_retry = __toESM(require("async-retry"));
|
|
39
39
|
var import_async_sema = require("async-sema");
|
|
40
40
|
var import_utils = require("./utils");
|
|
@@ -82,8 +82,8 @@ async function* upload(files, clientOptions, deploymentOptions) {
|
|
|
82
82
|
debug("Building an upload list...");
|
|
83
83
|
const semaphore = new import_async_sema.Sema(50, { capacity: 50 });
|
|
84
84
|
const defaultAgent = apiUrl?.startsWith("https://") ? new import_https.default.Agent({ keepAlive: true }) : new import_http.default.Agent({ keepAlive: true });
|
|
85
|
-
const
|
|
86
|
-
|
|
85
|
+
const abortControllers = /* @__PURE__ */ new Set();
|
|
86
|
+
let aborted = false;
|
|
87
87
|
shas.forEach((sha, index) => {
|
|
88
88
|
const uploadProgress = uploads[index];
|
|
89
89
|
uploadList[sha] = (0, import_async_retry.default)(
|
|
@@ -94,6 +94,9 @@ async function* upload(files, clientOptions, deploymentOptions) {
|
|
|
94
94
|
return bail(new Error(`File ${sha} is undefined`));
|
|
95
95
|
}
|
|
96
96
|
await semaphore.acquire();
|
|
97
|
+
if (aborted) {
|
|
98
|
+
return bail(new Error("Upload aborted"));
|
|
99
|
+
}
|
|
97
100
|
const { data } = file;
|
|
98
101
|
if (typeof data === "undefined") {
|
|
99
102
|
return;
|
|
@@ -117,6 +120,8 @@ async function* upload(files, clientOptions, deploymentOptions) {
|
|
|
117
120
|
body.push(null);
|
|
118
121
|
let err;
|
|
119
122
|
let result;
|
|
123
|
+
const abortController = new AbortController();
|
|
124
|
+
abortControllers.add(abortController);
|
|
120
125
|
try {
|
|
121
126
|
const res = await (0, import_utils.fetch)(
|
|
122
127
|
import_utils.API_FILES,
|
|
@@ -170,10 +175,14 @@ ${e}`);
|
|
|
170
175
|
throw err;
|
|
171
176
|
} else {
|
|
172
177
|
debug("Other error, bailing: " + err.message);
|
|
173
|
-
|
|
178
|
+
if (!aborted) {
|
|
179
|
+
aborted = true;
|
|
180
|
+
abortControllers.forEach((controller) => controller.abort());
|
|
181
|
+
}
|
|
174
182
|
return bail(err);
|
|
175
183
|
}
|
|
176
184
|
}
|
|
185
|
+
abortControllers.delete(abortController);
|
|
177
186
|
return result;
|
|
178
187
|
},
|
|
179
188
|
{
|
|
@@ -186,9 +195,7 @@ ${e}`);
|
|
|
186
195
|
debug("Starting upload");
|
|
187
196
|
while (Object.keys(uploadList).length > 0) {
|
|
188
197
|
try {
|
|
189
|
-
const event = await Promise.race(
|
|
190
|
-
Object.keys(uploadList).map((key) => uploadList[key])
|
|
191
|
-
);
|
|
198
|
+
const event = await Promise.race(Object.values(uploadList));
|
|
192
199
|
delete uploadList[event.payload.sha];
|
|
193
200
|
yield event;
|
|
194
201
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/client",
|
|
3
|
-
"version": "13.4.
|
|
3
|
+
"version": "13.4.20",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"homepage": "https://vercel.com",
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
"@types/recursive-readdir": "2.2.0",
|
|
28
28
|
"@types/tar-fs": "1.16.1",
|
|
29
29
|
"jest-junit": "16.0.0",
|
|
30
|
+
"vitest": "2.0.1",
|
|
30
31
|
"typescript": "4.9.5"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@vercel/build-utils": "8.
|
|
34
|
+
"@vercel/build-utils": "8.6.0",
|
|
34
35
|
"@vercel/error-utils": "2.0.3",
|
|
35
36
|
"@vercel/routing-utils": "3.1.0",
|
|
36
37
|
"async-retry": "1.2.3",
|
|
@@ -46,9 +47,10 @@
|
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"build": "node ../../utils/build.mjs",
|
|
49
|
-
"test-e2e": "pnpm test tests/create-deployment.test.ts tests/create-legacy-deployment.test.ts tests/paths.test.ts",
|
|
50
50
|
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
|
|
51
|
-
"
|
|
51
|
+
"vitest-run": "vitest -c ./vitest.config.mts",
|
|
52
|
+
"vitest-unit": "glob --absolute 'tests/unit.*.test.ts'",
|
|
53
|
+
"vitest-e2e": "glob --absolute 'tests/integration-*.test.ts'",
|
|
52
54
|
"type-check": "tsc --noEmit"
|
|
53
55
|
}
|
|
54
56
|
}
|