@mutmutco/hub 4.3.38 → 4.3.40

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.
Files changed (2) hide show
  1. package/dist/index.cjs +17 -7
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -60,6 +60,7 @@ __export(index_exports, {
60
60
  progressiveRow: () => progressiveRow,
61
61
  readLaunchTarget: () => readLaunchTarget,
62
62
  readPending: () => readPending,
63
+ reconcile: () => reconcile,
63
64
  reconcileCursorUserHooks: () => reconcileCursorUserHooks,
64
65
  releaseSharedDocLock: () => releaseSharedDocLock,
65
66
  reportFooterLines: () => reportFooterLines,
@@ -146,8 +147,8 @@ function readLease(path) {
146
147
  return null;
147
148
  }
148
149
  }
149
- function withLease(path, fn) {
150
- const deadline = Date.now() + LEASE_WAIT_MS;
150
+ function withLease(path, fn, waitMs = LEASE_WAIT_MS) {
151
+ const deadline = Date.now() + waitMs;
151
152
  for (; ; ) {
152
153
  const attempt = tryAcquire(path);
153
154
  if (typeof attempt === "object") {
@@ -158,9 +159,9 @@ function withLease(path, fn) {
158
159
  }
159
160
  }
160
161
  if (Date.now() >= deadline) {
161
- throw new UpdaterBusy(`another updater holds ${path} (waited ${LEASE_WAIT_MS}ms) \u2014 deferring`);
162
+ throw new UpdaterBusy(`another updater holds ${path} (waited ${waitMs}ms) \u2014 deferring`);
162
163
  }
163
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 500);
164
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Math.min(500, Math.max(1, deadline - Date.now())));
164
165
  }
165
166
  }
166
167
  function appendJournal(path, event) {
@@ -2030,6 +2031,7 @@ function reconcile(options) {
2030
2031
  };
2031
2032
  try {
2032
2033
  say("acquiring single-writer lease");
2034
+ const leaseWaitMs = Number(env.MMI_UPDATER_LEASE_WAIT_MS) || void 0;
2033
2035
  return withLease(paths.leasePath, () => {
2034
2036
  if (!options.dryRun) {
2035
2037
  const pendingBefore = readPending(paths);
@@ -2143,9 +2145,16 @@ function reconcile(options) {
2143
2145
  }
2144
2146
  }
2145
2147
  return summary;
2146
- });
2148
+ }, leaseWaitMs);
2147
2149
  } catch (error) {
2148
- if (error instanceof UpdaterBusy || error instanceof GateEnvError) {
2150
+ if (error instanceof UpdaterBusy) {
2151
+ journal({ kind: "reconcile", verdict: "defer", detail: error.message });
2152
+ summary.exit = 0;
2153
+ summary.deferred = true;
2154
+ summary.detail = error.message;
2155
+ return summary;
2156
+ }
2157
+ if (error instanceof GateEnvError) {
2149
2158
  journal({ kind: "reconcile", verdict: "defer", detail: error.message });
2150
2159
  summary.exit = 1;
2151
2160
  summary.detail = error.message;
@@ -2941,7 +2950,7 @@ function formatReconcileReport(summary, options = {}) {
2941
2950
  total: rows.length
2942
2951
  };
2943
2952
  if (!summary.target) {
2944
- if (summary.exit >= 1 && summary.detail) {
2953
+ if ((summary.exit >= 1 || summary.deferred) && summary.detail) {
2945
2954
  out.push("MMI Hub \u2014 cannot update now");
2946
2955
  out.push(...noteLines(" " + paint("failed", "blocked"), headline(summary.detail, width), width));
2947
2956
  out.push(...noteLines(" fix:", retryHint(summary.detail), width));
@@ -3291,6 +3300,7 @@ if (typeof require !== "undefined" && require.main === module) {
3291
3300
  progressiveRow,
3292
3301
  readLaunchTarget,
3293
3302
  readPending,
3303
+ reconcile,
3294
3304
  reconcileCursorUserHooks,
3295
3305
  releaseSharedDocLock,
3296
3306
  reportFooterLines,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutmutco/hub",
3
- "version": "4.3.38",
3
+ "version": "4.3.40",
4
4
  "description": "Install and maintain the MMI CLI and every present host surface from one release-gated Hub command.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",