@hot-updater/azure 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/functions/index.mjs +42 -17
- package/package.json +6 -6
package/dist/functions/index.mjs
CHANGED
|
@@ -6743,7 +6743,7 @@ const build = (changes, current) => {
|
|
|
6743
6743
|
return changes.map((change, at) => rewrites(change) ? rewrite(change, keys[at], current.get(rowId(change.model, keys[at])) ?? null) : increment(change, keys[at]));
|
|
6744
6744
|
};
|
|
6745
6745
|
const isOp = (op) => op !== void 0;
|
|
6746
|
-
const sleep$
|
|
6746
|
+
const sleep$3 = (attempt) => new Promise((resolve) => setTimeout(resolve, Math.min(250, 5 * 2 ** attempt) * Math.random()));
|
|
6747
6747
|
const pack = (text) => {
|
|
6748
6748
|
const runs = (text.match(/(.)\1*/gsu) ?? []).flatMap((run) => [run[0], run.length]);
|
|
6749
6749
|
return JSON.stringify(runs).length < JSON.stringify(text).length ? runs : text;
|
|
@@ -6862,7 +6862,7 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { windowMs
|
|
|
6862
6862
|
const result = await adapter.write(ops);
|
|
6863
6863
|
if (result.ok) return true;
|
|
6864
6864
|
if (!("retry" in result)) return false;
|
|
6865
|
-
await sleep$
|
|
6865
|
+
await sleep$3(failures);
|
|
6866
6866
|
}
|
|
6867
6867
|
return false;
|
|
6868
6868
|
};
|
|
@@ -7805,6 +7805,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
7805
7805
|
let negative;
|
|
7806
7806
|
let failures = 0;
|
|
7807
7807
|
let lost;
|
|
7808
|
+
let busy = false;
|
|
7808
7809
|
for (let round = 0;; round += 1) {
|
|
7809
7810
|
const delay = round && Math.min(maxDelayMs, baseDelayMs * 2 ** (round - 1));
|
|
7810
7811
|
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay / 2 + Math.random() * (delay / 2)));
|
|
@@ -7815,6 +7816,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
7815
7816
|
if (run === void 0) {
|
|
7816
7817
|
onRetry?.("rerun", round + 1);
|
|
7817
7818
|
lost = void 0;
|
|
7819
|
+
busy = false;
|
|
7818
7820
|
if ((failures += 1) >= attempts) break;
|
|
7819
7821
|
continue;
|
|
7820
7822
|
}
|
|
@@ -7825,6 +7827,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
7825
7827
|
if (!(error instanceof NegativeGaugeError)) throw error;
|
|
7826
7828
|
negative = error;
|
|
7827
7829
|
onRetry?.("rerun", round + 1);
|
|
7830
|
+
busy = false;
|
|
7828
7831
|
run = void 0;
|
|
7829
7832
|
lost = void 0;
|
|
7830
7833
|
if ((failures += 1) >= attempts) break;
|
|
@@ -7845,6 +7848,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
7845
7848
|
}
|
|
7846
7849
|
if (outcome.ok) return run.result;
|
|
7847
7850
|
const failed = "failedOp" in outcome ? outcome.failedOp : void 0;
|
|
7851
|
+
busy = failed === void 0;
|
|
7848
7852
|
if (failed === void 0 || failed >= run.ops.length) {
|
|
7849
7853
|
onRetry?.("resend", round + 1);
|
|
7850
7854
|
failures += 1;
|
|
@@ -7858,7 +7862,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
7858
7862
|
run = void 0;
|
|
7859
7863
|
if ((failures += 1) >= attempts) break;
|
|
7860
7864
|
}
|
|
7861
|
-
throw negative ?? new DatabaseConflictError(`The transaction conflicted ${attempts} times.`);
|
|
7865
|
+
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.`);
|
|
7862
7866
|
} };
|
|
7863
7867
|
};
|
|
7864
7868
|
//#endregion
|
|
@@ -8484,7 +8488,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
8484
8488
|
};
|
|
8485
8489
|
//#endregion
|
|
8486
8490
|
//#region ../../packages/server/dist/version.mjs
|
|
8487
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
8491
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.59";
|
|
8488
8492
|
//#endregion
|
|
8489
8493
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
8490
8494
|
const createVersionRouteHandlers = (plugins = []) => {
|
|
@@ -9874,10 +9878,14 @@ const createLabelAllocator = (tx, used, caughtUp) => {
|
|
|
9874
9878
|
};
|
|
9875
9879
|
const FILL_BATCH = 25;
|
|
9876
9880
|
const PAGE$4 = 500;
|
|
9881
|
+
const PAUSE_MS$1 = 1e3;
|
|
9882
|
+
const MAX_PAUSE_MS$1 = 32e3;
|
|
9883
|
+
const sleep$2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9877
9884
|
const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {}) => {
|
|
9878
9885
|
const id = labelSequenceId(channelId, platform);
|
|
9879
9886
|
let labeled = 0;
|
|
9880
9887
|
let batchSize = FILL_BATCH;
|
|
9888
|
+
let paused = 0;
|
|
9881
9889
|
const label = async (ids) => {
|
|
9882
9890
|
for (let at = 0; at < ids.length;) {
|
|
9883
9891
|
const batch = ids.slice(at, at + batchSize);
|
|
@@ -9902,12 +9910,16 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
9902
9910
|
return count;
|
|
9903
9911
|
});
|
|
9904
9912
|
at += batch.length;
|
|
9913
|
+
paused = 0;
|
|
9905
9914
|
} catch (error) {
|
|
9906
9915
|
if (batchSize > 1 && error instanceof DatabaseConstraintError && error.reason === "too_large") {
|
|
9907
9916
|
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
9908
9917
|
continue;
|
|
9909
9918
|
}
|
|
9910
|
-
throw error;
|
|
9919
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS$1) throw error;
|
|
9920
|
+
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
9921
|
+
paused = paused === 0 ? PAUSE_MS$1 : paused * 2;
|
|
9922
|
+
await sleep$2(paused);
|
|
9911
9923
|
}
|
|
9912
9924
|
}
|
|
9913
9925
|
};
|
|
@@ -13303,6 +13315,9 @@ createInsightsSchema();
|
|
|
13303
13315
|
//#region ../insights/dist/server/backfill.mjs
|
|
13304
13316
|
const PAGE$1 = 500;
|
|
13305
13317
|
const BATCH = 25;
|
|
13318
|
+
const PAUSE_MS = 1e3;
|
|
13319
|
+
const MAX_PAUSE_MS = 32e3;
|
|
13320
|
+
const sleep$1 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
13306
13321
|
const sameRefs = (stored, refs) => {
|
|
13307
13322
|
const values = Array.isArray(stored) ? stored : [];
|
|
13308
13323
|
return values.length === refs.length && values.every((value) => refs.includes(value));
|
|
@@ -13314,19 +13329,30 @@ const namesArtifact = (row) => {
|
|
|
13314
13329
|
const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}) => {
|
|
13315
13330
|
const today = now() - now() % DAY_MS$1;
|
|
13316
13331
|
let events = 0;
|
|
13317
|
-
|
|
13332
|
+
let size = BATCH;
|
|
13333
|
+
let paused = 0;
|
|
13334
|
+
const move = async (stale) => {
|
|
13318
13335
|
if (dryRun) {
|
|
13319
|
-
events +=
|
|
13336
|
+
events += stale.length;
|
|
13320
13337
|
return;
|
|
13321
13338
|
}
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13339
|
+
for (let start = 0; start < stale.length;) {
|
|
13340
|
+
const candidates = stale.slice(start, start + size);
|
|
13341
|
+
try {
|
|
13342
|
+
events += await rewrite(candidates);
|
|
13343
|
+
start += candidates.length;
|
|
13344
|
+
paused = 0;
|
|
13345
|
+
} catch (error) {
|
|
13346
|
+
if (error instanceof DatabaseConstraintError && error.reason === "too_large" && candidates.length > 1) {
|
|
13347
|
+
size = Math.ceil(candidates.length / 2);
|
|
13348
|
+
continue;
|
|
13349
|
+
}
|
|
13350
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS) throw error;
|
|
13351
|
+
size = Math.ceil(candidates.length / 2);
|
|
13352
|
+
paused = paused === 0 ? PAUSE_MS : paused * 2;
|
|
13353
|
+
await sleep$1(paused);
|
|
13354
|
+
}
|
|
13355
|
+
}
|
|
13330
13356
|
};
|
|
13331
13357
|
const rewrite = (candidates) => db.transaction(async (tx) => {
|
|
13332
13358
|
const rows = await Promise.all(candidates.map(({ id }) => tx.findOne("bundle_events", { id })));
|
|
@@ -13356,8 +13382,7 @@ const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}
|
|
|
13356
13382
|
limit: PAGE$1,
|
|
13357
13383
|
...cursor === void 0 ? {} : { cursor }
|
|
13358
13384
|
});
|
|
13359
|
-
|
|
13360
|
-
for (let start = 0; start < stale.length; start += BATCH) await move(stale.slice(start, start + BATCH));
|
|
13385
|
+
await move(page.rows.filter(namesArtifact));
|
|
13361
13386
|
cursor = page.next;
|
|
13362
13387
|
} while (cursor !== void 0);
|
|
13363
13388
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/azure",
|
|
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
|
"engines": {
|
|
7
7
|
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@azure/identity": "4.14.0",
|
|
45
45
|
"@azure/keyvault-secrets": "4.11.2",
|
|
46
46
|
"@azure/storage-blob": "12.34.0",
|
|
47
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
48
|
-
"@hot-updater/plugin-core": "1.2.0-rc.
|
|
49
|
-
"@hot-updater/protocol": "1.2.0-rc.
|
|
50
|
-
"@hot-updater/server": "1.2.0-rc.
|
|
47
|
+
"@hot-updater/cli-tools": "1.2.0-rc.59",
|
|
48
|
+
"@hot-updater/plugin-core": "1.2.0-rc.59",
|
|
49
|
+
"@hot-updater/protocol": "1.2.0-rc.59",
|
|
50
|
+
"@hot-updater/server": "1.2.0-rc.59"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@azure/functions": "4.16.5",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"execa": "9.5.2",
|
|
56
56
|
"jszip": "^3.10.1",
|
|
57
57
|
"vitest": "4.1.4",
|
|
58
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
58
|
+
"@hot-updater/test-utils": "1.2.0-rc.59"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "tsdown",
|