@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.
@@ -173,22 +173,36 @@ export async function autoProvision(opts) {
173
173
  });
174
174
  let treeId;
175
175
  let digest;
176
- try {
177
- ({ treeId, digest } = await memClient.initTree(accountId, opts.defaultBranch ?? "main"));
178
- }
179
- catch (e) {
180
- const msg = String(e);
181
- console.log(chalk.red("failed"));
182
- if (msg.includes("429") || msg.toLowerCase().includes("rate limit")) {
183
- throw new Error("Sponsor rate limit hit for init_tree (1/IP/day).\n" +
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
- if (msg.includes("Sponsor error: 404")) {
188
- throw new Error(`Sponsor endpoint not reachable (${sponsorEndpoint}).\n` +
189
- "Set MEMFORK_SPONSOR_URL to your sponsor base URL and retry.");
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.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memfork/cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "MemForks CLI — init, commit, recall, merge, install plugins",
5
5
  "repository": {
6
6
  "type": "git",