@hot-updater/vercel 1.2.0-rc.58 → 1.2.0-rc.59
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/function/index.mjs +42 -17
- package/package.json +7 -7
package/dist/function/index.mjs
CHANGED
|
@@ -3178,7 +3178,7 @@ const build = (changes, current) => {
|
|
|
3178
3178
|
return changes.map((change, at) => rewrites(change) ? rewrite$1(change, keys[at], current.get(rowId(change.model, keys[at])) ?? null) : increment(change, keys[at]));
|
|
3179
3179
|
};
|
|
3180
3180
|
const isOp = (op) => op !== void 0;
|
|
3181
|
-
const sleep = (attempt) => new Promise((resolve) => setTimeout(resolve, Math.min(250, 5 * 2 ** attempt) * Math.random()));
|
|
3181
|
+
const sleep$2 = (attempt) => new Promise((resolve) => setTimeout(resolve, Math.min(250, 5 * 2 ** attempt) * Math.random()));
|
|
3182
3182
|
const pack = (text) => {
|
|
3183
3183
|
const runs = (text.match(/(.)\1*/gsu) ?? []).flatMap((run) => [run[0], run.length]);
|
|
3184
3184
|
return JSON.stringify(runs).length < JSON.stringify(text).length ? runs : text;
|
|
@@ -3297,7 +3297,7 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { windowMs
|
|
|
3297
3297
|
const result = await adapter.write(ops);
|
|
3298
3298
|
if (result.ok) return true;
|
|
3299
3299
|
if (!("retry" in result)) return false;
|
|
3300
|
-
await sleep(failures);
|
|
3300
|
+
await sleep$2(failures);
|
|
3301
3301
|
}
|
|
3302
3302
|
return false;
|
|
3303
3303
|
};
|
|
@@ -4231,6 +4231,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4231
4231
|
let negative;
|
|
4232
4232
|
let failures = 0;
|
|
4233
4233
|
let lost;
|
|
4234
|
+
let busy = false;
|
|
4234
4235
|
for (let round = 0;; round += 1) {
|
|
4235
4236
|
const delay = round && Math.min(maxDelayMs, baseDelayMs * 2 ** (round - 1));
|
|
4236
4237
|
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay / 2 + Math.random() * (delay / 2)));
|
|
@@ -4241,6 +4242,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4241
4242
|
if (run === void 0) {
|
|
4242
4243
|
onRetry?.("rerun", round + 1);
|
|
4243
4244
|
lost = void 0;
|
|
4245
|
+
busy = false;
|
|
4244
4246
|
if ((failures += 1) >= attempts) break;
|
|
4245
4247
|
continue;
|
|
4246
4248
|
}
|
|
@@ -4251,6 +4253,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4251
4253
|
if (!(error instanceof NegativeGaugeError)) throw error;
|
|
4252
4254
|
negative = error;
|
|
4253
4255
|
onRetry?.("rerun", round + 1);
|
|
4256
|
+
busy = false;
|
|
4254
4257
|
run = void 0;
|
|
4255
4258
|
lost = void 0;
|
|
4256
4259
|
if ((failures += 1) >= attempts) break;
|
|
@@ -4271,6 +4274,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4271
4274
|
}
|
|
4272
4275
|
if (outcome.ok) return run.result;
|
|
4273
4276
|
const failed = "failedOp" in outcome ? outcome.failedOp : void 0;
|
|
4277
|
+
busy = failed === void 0;
|
|
4274
4278
|
if (failed === void 0 || failed >= run.ops.length) {
|
|
4275
4279
|
onRetry?.("resend", round + 1);
|
|
4276
4280
|
failures += 1;
|
|
@@ -4284,7 +4288,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4284
4288
|
run = void 0;
|
|
4285
4289
|
if ((failures += 1) >= attempts) break;
|
|
4286
4290
|
}
|
|
4287
|
-
throw negative ?? new DatabaseConflictError(`The transaction conflicted ${attempts} times.`);
|
|
4291
|
+
throw negative ?? new DatabaseConflictError(busy ? `The database stayed busy through ${attempts} attempts of the transaction, as a store does at its throughput limit.` : `The transaction conflicted ${attempts} times.`);
|
|
4288
4292
|
} };
|
|
4289
4293
|
};
|
|
4290
4294
|
//#endregion
|
|
@@ -18083,7 +18087,7 @@ const postgres = (config) => {
|
|
|
18083
18087
|
};
|
|
18084
18088
|
//#endregion
|
|
18085
18089
|
//#region ../../packages/server/dist/version.mjs
|
|
18086
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
18090
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.59";
|
|
18087
18091
|
//#endregion
|
|
18088
18092
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
18089
18093
|
const createVersionRouteHandlers = (plugins = []) => {
|
|
@@ -19473,10 +19477,14 @@ const createLabelAllocator = (tx, used, caughtUp) => {
|
|
|
19473
19477
|
};
|
|
19474
19478
|
const FILL_BATCH = 25;
|
|
19475
19479
|
const PAGE$4 = 500;
|
|
19480
|
+
const PAUSE_MS$1 = 1e3;
|
|
19481
|
+
const MAX_PAUSE_MS$1 = 32e3;
|
|
19482
|
+
const sleep$1 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
19476
19483
|
const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {}) => {
|
|
19477
19484
|
const id = labelSequenceId(channelId, platform);
|
|
19478
19485
|
let labeled = 0;
|
|
19479
19486
|
let batchSize = FILL_BATCH;
|
|
19487
|
+
let paused = 0;
|
|
19480
19488
|
const label = async (ids) => {
|
|
19481
19489
|
for (let at = 0; at < ids.length;) {
|
|
19482
19490
|
const batch = ids.slice(at, at + batchSize);
|
|
@@ -19501,12 +19509,16 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
19501
19509
|
return count;
|
|
19502
19510
|
});
|
|
19503
19511
|
at += batch.length;
|
|
19512
|
+
paused = 0;
|
|
19504
19513
|
} catch (error) {
|
|
19505
19514
|
if (batchSize > 1 && error instanceof DatabaseConstraintError && error.reason === "too_large") {
|
|
19506
19515
|
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
19507
19516
|
continue;
|
|
19508
19517
|
}
|
|
19509
|
-
throw error;
|
|
19518
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS$1) throw error;
|
|
19519
|
+
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
19520
|
+
paused = paused === 0 ? PAUSE_MS$1 : paused * 2;
|
|
19521
|
+
await sleep$1(paused);
|
|
19510
19522
|
}
|
|
19511
19523
|
}
|
|
19512
19524
|
};
|
|
@@ -22902,6 +22914,9 @@ createInsightsSchema();
|
|
|
22902
22914
|
//#region ../insights/dist/server/backfill.mjs
|
|
22903
22915
|
const PAGE$1 = 500;
|
|
22904
22916
|
const BATCH = 25;
|
|
22917
|
+
const PAUSE_MS = 1e3;
|
|
22918
|
+
const MAX_PAUSE_MS = 32e3;
|
|
22919
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
22905
22920
|
const sameRefs = (stored, refs) => {
|
|
22906
22921
|
const values = Array.isArray(stored) ? stored : [];
|
|
22907
22922
|
return values.length === refs.length && values.every((value) => refs.includes(value));
|
|
@@ -22913,19 +22928,30 @@ const namesArtifact = (row) => {
|
|
|
22913
22928
|
const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}) => {
|
|
22914
22929
|
const today = now() - now() % DAY_MS$1;
|
|
22915
22930
|
let events = 0;
|
|
22916
|
-
|
|
22931
|
+
let size = BATCH;
|
|
22932
|
+
let paused = 0;
|
|
22933
|
+
const move = async (stale) => {
|
|
22917
22934
|
if (dryRun) {
|
|
22918
|
-
events +=
|
|
22935
|
+
events += stale.length;
|
|
22919
22936
|
return;
|
|
22920
22937
|
}
|
|
22921
|
-
|
|
22922
|
-
|
|
22923
|
-
|
|
22924
|
-
|
|
22925
|
-
|
|
22926
|
-
|
|
22927
|
-
|
|
22928
|
-
|
|
22938
|
+
for (let start = 0; start < stale.length;) {
|
|
22939
|
+
const candidates = stale.slice(start, start + size);
|
|
22940
|
+
try {
|
|
22941
|
+
events += await rewrite(candidates);
|
|
22942
|
+
start += candidates.length;
|
|
22943
|
+
paused = 0;
|
|
22944
|
+
} catch (error) {
|
|
22945
|
+
if (error instanceof DatabaseConstraintError && error.reason === "too_large" && candidates.length > 1) {
|
|
22946
|
+
size = Math.ceil(candidates.length / 2);
|
|
22947
|
+
continue;
|
|
22948
|
+
}
|
|
22949
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS) throw error;
|
|
22950
|
+
size = Math.ceil(candidates.length / 2);
|
|
22951
|
+
paused = paused === 0 ? PAUSE_MS : paused * 2;
|
|
22952
|
+
await sleep(paused);
|
|
22953
|
+
}
|
|
22954
|
+
}
|
|
22929
22955
|
};
|
|
22930
22956
|
const rewrite = (candidates) => db.transaction(async (tx) => {
|
|
22931
22957
|
const rows = await Promise.all(candidates.map(({ id }) => tx.findOne("bundle_events", { id })));
|
|
@@ -22955,8 +22981,7 @@ const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}
|
|
|
22955
22981
|
limit: PAGE$1,
|
|
22956
22982
|
...cursor === void 0 ? {} : { cursor }
|
|
22957
22983
|
});
|
|
22958
|
-
|
|
22959
|
-
for (let start = 0; start < stale.length; start += BATCH) await move(stale.slice(start, start + BATCH));
|
|
22984
|
+
await move(page.rows.filter(namesArtifact));
|
|
22960
22985
|
cursor = page.next;
|
|
22961
22986
|
} while (cursor !== void 0);
|
|
22962
22987
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/vercel",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-rc.
|
|
4
|
+
"version": "1.2.0-rc.59",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"@vercel/cli-auth": "0.3.10",
|
|
42
42
|
"@vercel/cli-config": "0.3.1",
|
|
43
43
|
"pg": "8.13.1",
|
|
44
|
-
"@hot-updater/
|
|
45
|
-
"@hot-updater/
|
|
46
|
-
"@hot-updater/
|
|
47
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
48
|
-
"@hot-updater/server": "1.2.0-rc.
|
|
44
|
+
"@hot-updater/plugin-core": "1.2.0-rc.59",
|
|
45
|
+
"@hot-updater/postgres": "1.2.0-rc.59",
|
|
46
|
+
"@hot-updater/cli-tools": "1.2.0-rc.59",
|
|
47
|
+
"@hot-updater/protocol": "1.2.0-rc.59",
|
|
48
|
+
"@hot-updater/server": "1.2.0-rc.59"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "^20",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"execa": "9.5.2",
|
|
55
55
|
"kysely": "0.28.17",
|
|
56
56
|
"vitest": "4.1.4",
|
|
57
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
57
|
+
"@hot-updater/test-utils": "1.2.0-rc.59"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsdown",
|