@memfork/cli 0.1.16 → 0.1.17
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/provision.js +28 -14
- package/package.json +1 -1
|
@@ -173,22 +173,36 @@ export async function autoProvision(opts) {
|
|
|
173
173
|
});
|
|
174
174
|
let treeId;
|
|
175
175
|
let digest;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
"Wait 24 h and run `memfork init --quick` again, or fund the wallet manually:\n" +
|
|
185
|
-
` ${address}`);
|
|
176
|
+
// Retry once on a transient gas-coin version race: the sponsor refreshes its
|
|
177
|
+
// pool after the drip, but if initTree lands before that completes the
|
|
178
|
+
// fullnode may report a stale-object error. A short wait + retry clears it.
|
|
179
|
+
const maxAttempts = 2;
|
|
180
|
+
for (let attempt = 1;; attempt++) {
|
|
181
|
+
try {
|
|
182
|
+
({ treeId, digest } = await memClient.initTree(accountId, opts.defaultBranch ?? "main"));
|
|
183
|
+
break;
|
|
186
184
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
catch (e) {
|
|
186
|
+
const msg = String(e);
|
|
187
|
+
const isTransient = msg.includes("needs to be rebuilt") ||
|
|
188
|
+
msg.includes("unavailable for consumption") ||
|
|
189
|
+
msg.includes("object version");
|
|
190
|
+
if (isTransient && attempt < maxAttempts) {
|
|
191
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
console.log(chalk.red("failed"));
|
|
195
|
+
if (msg.includes("429") || msg.toLowerCase().includes("rate limit")) {
|
|
196
|
+
throw new Error("Sponsor rate limit hit for init_tree (1/IP/day).\n" +
|
|
197
|
+
"Wait 24 h and run `memfork init --quick` again, or fund the wallet manually:\n" +
|
|
198
|
+
` ${address}`);
|
|
199
|
+
}
|
|
200
|
+
if (msg.includes("Sponsor error: 404")) {
|
|
201
|
+
throw new Error(`Sponsor endpoint not reachable (${sponsorEndpoint}).\n` +
|
|
202
|
+
"Set MEMFORK_SPONSOR_URL to your sponsor base URL and retry.");
|
|
203
|
+
}
|
|
204
|
+
throw new Error(`MemoryTree creation failed: ${msg}`);
|
|
190
205
|
}
|
|
191
|
-
throw new Error(`MemoryTree creation failed: ${msg}`);
|
|
192
206
|
}
|
|
193
207
|
if (!treeId) {
|
|
194
208
|
throw new Error("MemoryTree creation returned no treeId — check sponsor logs.");
|