@memfork/cli 0.1.23 → 0.1.24
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/commands/ops.js +23 -3
- package/package.json +1 -1
package/dist/commands/ops.js
CHANGED
|
@@ -14,6 +14,26 @@ async function getClient() {
|
|
|
14
14
|
const client = await MemForksClient.connect(toClientConfig(cfg));
|
|
15
15
|
return { client, cfg };
|
|
16
16
|
}
|
|
17
|
+
function isTransientSuiError(e) {
|
|
18
|
+
const msg = String(e);
|
|
19
|
+
return (msg.includes("needs to be rebuilt") ||
|
|
20
|
+
msg.includes("unavailable for consumption") ||
|
|
21
|
+
msg.includes("object version"));
|
|
22
|
+
}
|
|
23
|
+
async function withRetry(fn, retries = 2, delayMs = 1500) {
|
|
24
|
+
for (let attempt = 1;; attempt++) {
|
|
25
|
+
try {
|
|
26
|
+
return await fn();
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
if (isTransientSuiError(e) && attempt < retries) {
|
|
30
|
+
await new Promise((r) => setTimeout(r, delayMs));
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
throw e;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
17
37
|
function currentGitBranch() {
|
|
18
38
|
try {
|
|
19
39
|
return execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf8" }).trim();
|
|
@@ -112,7 +132,7 @@ export async function cmdCommit(opts) {
|
|
|
112
132
|
console.error(chalk.red("No facts to commit. Pass --facts or --from-response."));
|
|
113
133
|
process.exit(1);
|
|
114
134
|
}
|
|
115
|
-
const { blobId } = await client.commit(branch, { facts, message: opts.message });
|
|
135
|
+
const { blobId } = await withRetry(() => client.commit(branch, { facts, message: opts.message }));
|
|
116
136
|
const out = { blobId, branch };
|
|
117
137
|
if (process.stdout.isTTY) {
|
|
118
138
|
console.log("");
|
|
@@ -138,7 +158,7 @@ export async function cmdMerge(from, into, opts) {
|
|
|
138
158
|
process.stdout.write(chalk.dim(`Merging ${chalk.green(from)} → ${chalk.green(into)}`) +
|
|
139
159
|
chalk.dim(governed ? " (governed — awaiting resolver…)" : " (LWW — self-finalizing…)") +
|
|
140
160
|
" ");
|
|
141
|
-
const { digest, mergedCount, blobId, proposalId } = await client.merge(from, into);
|
|
161
|
+
const { digest, mergedCount, blobId, proposalId } = await withRetry(() => client.merge(from, into));
|
|
142
162
|
console.log(chalk.green("done"));
|
|
143
163
|
console.log("");
|
|
144
164
|
console.log(chalk.dim(` facts merged: ${mergedCount}`));
|
|
@@ -574,7 +594,7 @@ export async function cmdBranch(name, opts = {}) {
|
|
|
574
594
|
const { client, cfg } = await getClient();
|
|
575
595
|
const from = opts.from ?? cfg.defaultBranch ?? currentGitBranch();
|
|
576
596
|
process.stdout.write(chalk.dim(`Creating branch ${chalk.green(name)} from ${chalk.green(from)} … `));
|
|
577
|
-
const digest = await client.branch(name, { from });
|
|
597
|
+
const digest = await withRetry(() => client.branch(name, { from }));
|
|
578
598
|
console.log(chalk.green("done"));
|
|
579
599
|
console.log("");
|
|
580
600
|
console.log(chalk.dim(` tx: ${digest}`));
|