@hot-updater/firebase 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/firebase/functions/index.cjs +56 -20
- package/dist/init/index.cjs +10 -1
- package/dist/init/index.mjs +10 -1
- package/package.json +7 -7
|
@@ -3286,7 +3286,7 @@ const build = (changes, current) => {
|
|
|
3286
3286
|
return changes.map((change, at) => rewrites(change) ? rewrite(change, keys[at], current.get(rowId(change.model, keys[at])) ?? null) : increment(change, keys[at]));
|
|
3287
3287
|
};
|
|
3288
3288
|
const isOp = (op) => op !== void 0;
|
|
3289
|
-
const sleep = (attempt) => new Promise((resolve) => setTimeout(resolve, Math.min(250, 5 * 2 ** attempt) * Math.random()));
|
|
3289
|
+
const sleep$2 = (attempt) => new Promise((resolve) => setTimeout(resolve, Math.min(250, 5 * 2 ** attempt) * Math.random()));
|
|
3290
3290
|
/** Runs of one character, where shorter: a sparse sketch packs into a few. */
|
|
3291
3291
|
const pack = (text) => {
|
|
3292
3292
|
const runs = (text.match(/(.)\1*/gsu) ?? []).flatMap((run) => [run[0], run.length]);
|
|
@@ -3435,7 +3435,7 @@ const createAggregateBatches = ({ engine, adapter, schema, batching: { windowMs
|
|
|
3435
3435
|
const result = await adapter.write(ops);
|
|
3436
3436
|
if (result.ok) return true;
|
|
3437
3437
|
if (!("retry" in result)) return false;
|
|
3438
|
-
await sleep(failures);
|
|
3438
|
+
await sleep$2(failures);
|
|
3439
3439
|
}
|
|
3440
3440
|
return false;
|
|
3441
3441
|
};
|
|
@@ -4449,6 +4449,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4449
4449
|
let negative;
|
|
4450
4450
|
let failures = 0;
|
|
4451
4451
|
let lost;
|
|
4452
|
+
let busy = false;
|
|
4452
4453
|
for (let round = 0;; round += 1) {
|
|
4453
4454
|
const delay = round && Math.min(maxDelayMs, baseDelayMs * 2 ** (round - 1));
|
|
4454
4455
|
if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay / 2 + Math.random() * (delay / 2)));
|
|
@@ -4459,6 +4460,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4459
4460
|
if (run === void 0) {
|
|
4460
4461
|
onRetry?.("rerun", round + 1);
|
|
4461
4462
|
lost = void 0;
|
|
4463
|
+
busy = false;
|
|
4462
4464
|
if ((failures += 1) >= attempts) break;
|
|
4463
4465
|
continue;
|
|
4464
4466
|
}
|
|
@@ -4469,6 +4471,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4469
4471
|
if (!(error instanceof NegativeGaugeError)) throw error;
|
|
4470
4472
|
negative = error;
|
|
4471
4473
|
onRetry?.("rerun", round + 1);
|
|
4474
|
+
busy = false;
|
|
4472
4475
|
run = void 0;
|
|
4473
4476
|
lost = void 0;
|
|
4474
4477
|
if ((failures += 1) >= attempts) break;
|
|
@@ -4489,6 +4492,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4489
4492
|
}
|
|
4490
4493
|
if (outcome.ok) return run.result;
|
|
4491
4494
|
const failed = "failedOp" in outcome ? outcome.failedOp : void 0;
|
|
4495
|
+
busy = failed === void 0;
|
|
4492
4496
|
if (failed === void 0 || failed >= run.ops.length) {
|
|
4493
4497
|
onRetry?.("resend", round + 1);
|
|
4494
4498
|
failures += 1;
|
|
@@ -4502,7 +4506,7 @@ const createTransactions = ({ adapter, schema, reads, retry = {} }) => {
|
|
|
4502
4506
|
run = void 0;
|
|
4503
4507
|
if ((failures += 1) >= attempts) break;
|
|
4504
4508
|
}
|
|
4505
|
-
throw negative ?? new DatabaseConflictError(`The transaction conflicted ${attempts} times.`);
|
|
4509
|
+
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.`);
|
|
4506
4510
|
} };
|
|
4507
4511
|
};
|
|
4508
4512
|
//#endregion
|
|
@@ -5199,7 +5203,7 @@ const createKvAdapter = ({ store, tablePrefix = "" }) => {
|
|
|
5199
5203
|
};
|
|
5200
5204
|
//#endregion
|
|
5201
5205
|
//#region ../../packages/server/dist/version.mjs
|
|
5202
|
-
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.
|
|
5206
|
+
const HOT_UPDATER_SERVER_VERSION = "1.2.0-rc.59";
|
|
5203
5207
|
//#endregion
|
|
5204
5208
|
//#region ../../packages/server/dist/handlerVersionRoutes.mjs
|
|
5205
5209
|
/**
|
|
@@ -6717,6 +6721,9 @@ const createLabelAllocator = (tx, used, caughtUp) => {
|
|
|
6717
6721
|
};
|
|
6718
6722
|
const FILL_BATCH = 25;
|
|
6719
6723
|
const PAGE$4 = 500;
|
|
6724
|
+
const PAUSE_MS$1 = 1e3;
|
|
6725
|
+
const MAX_PAUSE_MS$1 = 32e3;
|
|
6726
|
+
const sleep$1 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
6720
6727
|
/**
|
|
6721
6728
|
* Labels a channel and platform's releases that have none, in ID order,
|
|
6722
6729
|
* which is the order they were created in, and marks its counter filled:
|
|
@@ -6728,6 +6735,7 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
6728
6735
|
const id = labelSequenceId(channelId, platform);
|
|
6729
6736
|
let labeled = 0;
|
|
6730
6737
|
let batchSize = FILL_BATCH;
|
|
6738
|
+
let paused = 0;
|
|
6731
6739
|
const label = async (ids) => {
|
|
6732
6740
|
for (let at = 0; at < ids.length;) {
|
|
6733
6741
|
const batch = ids.slice(at, at + batchSize);
|
|
@@ -6752,12 +6760,16 @@ const fillLabels = async (db, { channelId, platform }, { dryRun = false } = {})
|
|
|
6752
6760
|
return count;
|
|
6753
6761
|
});
|
|
6754
6762
|
at += batch.length;
|
|
6763
|
+
paused = 0;
|
|
6755
6764
|
} catch (error) {
|
|
6756
6765
|
if (batchSize > 1 && error instanceof DatabaseConstraintError && error.reason === "too_large") {
|
|
6757
6766
|
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
6758
6767
|
continue;
|
|
6759
6768
|
}
|
|
6760
|
-
throw error;
|
|
6769
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS$1) throw error;
|
|
6770
|
+
batchSize = Math.max(1, Math.floor(batchSize / 2));
|
|
6771
|
+
paused = paused === 0 ? PAUSE_MS$1 : paused * 2;
|
|
6772
|
+
await sleep$1(paused);
|
|
6761
6773
|
}
|
|
6762
6774
|
}
|
|
6763
6775
|
};
|
|
@@ -10558,12 +10570,26 @@ createInsightsSchema();
|
|
|
10558
10570
|
//#region ../insights/dist/server/backfill.mjs
|
|
10559
10571
|
/**
|
|
10560
10572
|
* Stored events read a page, and rewritten up to `BATCH` a transaction. A
|
|
10561
|
-
*
|
|
10562
|
-
*
|
|
10563
|
-
*
|
|
10573
|
+
* run keeps one batch size, which only shrinks, halving whenever a store
|
|
10574
|
+
* refuses a batch:
|
|
10575
|
+
* - as too large, before writing anything: DynamoDB's 100 items hold fewer
|
|
10576
|
+
* than 25 rewrites with their index copies and counts;
|
|
10577
|
+
* - as busy through the transaction's retries: a write-capacity cap, such as
|
|
10578
|
+
* the 100 write units a second `hot-updater init` gives a DynamoDB table,
|
|
10579
|
+
* throttles a transaction that costs more than the cap admits, about 13
|
|
10580
|
+
* rewrites of 2 KB events there, and refuses every write for seconds once
|
|
10581
|
+
* the run has spent it.
|
|
10582
|
+
* After a busy refusal the run also waits before it writes again, `PAUSE_MS`
|
|
10583
|
+
* and twice as long after each further one, so the cap refills; a commit
|
|
10584
|
+
* starts the waits over. A batch the store still refuses after the
|
|
10585
|
+
* `MAX_PAUSE_MS` wait, or a one-event batch too large to write, fails the
|
|
10586
|
+
* run, which a rerun resumes.
|
|
10564
10587
|
*/
|
|
10565
10588
|
const PAGE$1 = 500;
|
|
10566
10589
|
const BATCH = 25;
|
|
10590
|
+
const PAUSE_MS = 1e3;
|
|
10591
|
+
const MAX_PAUSE_MS = 32e3;
|
|
10592
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10567
10593
|
const sameRefs = (stored, refs) => {
|
|
10568
10594
|
const values = Array.isArray(stored) ? stored : [];
|
|
10569
10595
|
return values.length === refs.length && values.every((value) => refs.includes(value));
|
|
@@ -10595,19 +10621,30 @@ const namesArtifact = (row) => {
|
|
|
10595
10621
|
const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}) => {
|
|
10596
10622
|
const today = now() - now() % DAY_MS$1;
|
|
10597
10623
|
let events = 0;
|
|
10598
|
-
|
|
10624
|
+
let size = BATCH;
|
|
10625
|
+
let paused = 0;
|
|
10626
|
+
const move = async (stale) => {
|
|
10599
10627
|
if (dryRun) {
|
|
10600
|
-
events +=
|
|
10628
|
+
events += stale.length;
|
|
10601
10629
|
return;
|
|
10602
10630
|
}
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10631
|
+
for (let start = 0; start < stale.length;) {
|
|
10632
|
+
const candidates = stale.slice(start, start + size);
|
|
10633
|
+
try {
|
|
10634
|
+
events += await rewrite(candidates);
|
|
10635
|
+
start += candidates.length;
|
|
10636
|
+
paused = 0;
|
|
10637
|
+
} catch (error) {
|
|
10638
|
+
if (error instanceof DatabaseConstraintError && error.reason === "too_large" && candidates.length > 1) {
|
|
10639
|
+
size = Math.ceil(candidates.length / 2);
|
|
10640
|
+
continue;
|
|
10641
|
+
}
|
|
10642
|
+
if (!isDatabaseBusyError(error) || paused >= MAX_PAUSE_MS) throw error;
|
|
10643
|
+
size = Math.ceil(candidates.length / 2);
|
|
10644
|
+
paused = paused === 0 ? PAUSE_MS : paused * 2;
|
|
10645
|
+
await sleep(paused);
|
|
10646
|
+
}
|
|
10647
|
+
}
|
|
10611
10648
|
};
|
|
10612
10649
|
const rewrite = (candidates) => db.transaction(async (tx) => {
|
|
10613
10650
|
const rows = await Promise.all(candidates.map(({ id }) => tx.findOne("bundle_events", { id })));
|
|
@@ -10637,8 +10674,7 @@ const backfillReleaseRefs = async (db, now, { rawDays }, { dryRun = false } = {}
|
|
|
10637
10674
|
limit: PAGE$1,
|
|
10638
10675
|
...cursor === void 0 ? {} : { cursor }
|
|
10639
10676
|
});
|
|
10640
|
-
|
|
10641
|
-
for (let start = 0; start < stale.length; start += BATCH) await move(stale.slice(start, start + BATCH));
|
|
10677
|
+
await move(page.rows.filter(namesArtifact));
|
|
10642
10678
|
cursor = page.next;
|
|
10643
10679
|
} while (cursor !== void 0);
|
|
10644
10680
|
}
|
package/dist/init/index.cjs
CHANGED
|
@@ -7950,7 +7950,6 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
7950
7950
|
try {
|
|
7951
7951
|
await migrateFirebaseDatabase(databaseConfig, server.plugins);
|
|
7952
7952
|
await (0, _hot_updater_cli_tools.fillReleaseLabels)(server);
|
|
7953
|
-
await (0, _hot_updater_cli_tools.backfillInsightsReleaseRefs)(server);
|
|
7954
7953
|
clientCredential = await (0, _hot_updater_cli_tools.provisionClientCredential)(server, {
|
|
7955
7954
|
env: initInputEnv,
|
|
7956
7955
|
name: "Firebase init"
|
|
@@ -8003,6 +8002,16 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
8003
8002
|
await removeTmpDir();
|
|
8004
8003
|
process.exit(1);
|
|
8005
8004
|
}
|
|
8005
|
+
const backfillDatabase = firebaseDatabase(databaseConfig);
|
|
8006
|
+
try {
|
|
8007
|
+
await (0, _hot_updater_cli_tools.backfillInsightsReleaseRefs)((0, _hot_updater_cli_tools.assembleServer)({
|
|
8008
|
+
database: backfillDatabase,
|
|
8009
|
+
plugins: server.plugins
|
|
8010
|
+
}));
|
|
8011
|
+
} finally {
|
|
8012
|
+
await backfillDatabase.dispose?.();
|
|
8013
|
+
await Promise.all((0, firebase_admin_app.getApps)().map((app) => (0, firebase_admin_app.deleteApp)(app)));
|
|
8014
|
+
}
|
|
8006
8015
|
await printTemplate(clientCredential, initializeVariable.projectId, currentRegion, server.clientPlugins, cliEnv);
|
|
8007
8016
|
await removeTmpDir();
|
|
8008
8017
|
return { nextSteps: [(0, _hot_updater_cli_tools.link)("https://hot-updater.dev/docs/managed/firebase#step-3-add-hotupdater-to-your-project"), ...applicationCredentials ? [] : ["Change GOOGLE_APPLICATION_CREDENTIALS=your-credentials.json in .env.hotupdater"]] };
|
package/dist/init/index.mjs
CHANGED
|
@@ -7943,7 +7943,6 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
7943
7943
|
try {
|
|
7944
7944
|
await migrateFirebaseDatabase(databaseConfig, server.plugins);
|
|
7945
7945
|
await fillReleaseLabels(server);
|
|
7946
|
-
await backfillInsightsReleaseRefs(server);
|
|
7947
7946
|
clientCredential = await provisionClientCredential(server, {
|
|
7948
7947
|
env: initInputEnv,
|
|
7949
7948
|
name: "Firebase init"
|
|
@@ -7996,6 +7995,16 @@ const runInit = async ({ build, envFile, secretsEnv }) => {
|
|
|
7996
7995
|
await removeTmpDir();
|
|
7997
7996
|
process.exit(1);
|
|
7998
7997
|
}
|
|
7998
|
+
const backfillDatabase = firebaseDatabase(databaseConfig);
|
|
7999
|
+
try {
|
|
8000
|
+
await backfillInsightsReleaseRefs(assembleServer({
|
|
8001
|
+
database: backfillDatabase,
|
|
8002
|
+
plugins: server.plugins
|
|
8003
|
+
}));
|
|
8004
|
+
} finally {
|
|
8005
|
+
await backfillDatabase.dispose?.();
|
|
8006
|
+
await Promise.all(getApps().map((app) => deleteApp(app)));
|
|
8007
|
+
}
|
|
7999
8008
|
await printTemplate(clientCredential, initializeVariable.projectId, currentRegion, server.clientPlugins, cliEnv);
|
|
8000
8009
|
await removeTmpDir();
|
|
8001
8010
|
return { nextSteps: [link("https://hot-updater.dev/docs/managed/firebase#step-3-add-hotupdater-to-your-project"), ...applicationCredentials ? [] : ["Change GOOGLE_APPLICATION_CREDENTIALS=your-credentials.json in .env.hotupdater"]] };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/firebase",
|
|
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
|
"types": "dist/index.d.cts",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"hono": "4.12.34",
|
|
40
40
|
"google-auth-library": "10.7.0",
|
|
41
|
-
"@hot-updater/cli-tools": "1.2.0-rc.
|
|
42
|
-
"@hot-updater/
|
|
43
|
-
"@hot-updater/
|
|
44
|
-
"@hot-updater/
|
|
41
|
+
"@hot-updater/cli-tools": "1.2.0-rc.59",
|
|
42
|
+
"@hot-updater/plugin-core": "1.2.0-rc.59",
|
|
43
|
+
"@hot-updater/protocol": "1.2.0-rc.59",
|
|
44
|
+
"@hot-updater/server": "1.2.0-rc.59"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"firebase-tools": "15.29.0",
|
|
57
57
|
"fkill": "^9.0.0",
|
|
58
58
|
"mime": "^4.0.4",
|
|
59
|
-
"@hot-updater/mock": "1.2.0-rc.
|
|
60
|
-
"@hot-updater/test-utils": "1.2.0-rc.
|
|
59
|
+
"@hot-updater/mock": "1.2.0-rc.59",
|
|
60
|
+
"@hot-updater/test-utils": "1.2.0-rc.59"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"firebase-admin": ">=11.10.0",
|