@myvillage/cli 1.88.1 → 1.88.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myvillage/cli",
3
- "version": "1.88.1",
3
+ "version": "1.88.3",
4
4
  "description": "MyVillageOS CLI for community developers",
5
5
  "type": "module",
6
6
  "bin": {
@@ -171,9 +171,12 @@ async function resolveMachineIdentity(opts) {
171
171
  }
172
172
 
173
173
  if (saved?.machineKey) {
174
- // Re-register with the stored credential so name/metadata/version refresh.
175
- const { machineId } = await register(makeClient(saved.machineKey, null), opts);
176
- persistRunnerState({ ...saved, machineId, name: opts.name || saved.name, registeredAt: new Date().toISOString() });
174
+ // Re-register with the stored credential so metadata/version refresh. Keep
175
+ // the name this machine already goes by unless a new one was asked for —
176
+ // restarting the runner must not rename the machine out from under the user.
177
+ const name = opts.name || saved.name || os.hostname();
178
+ const { machineId } = await register(makeClient(saved.machineKey, null), { ...opts, name });
179
+ persistRunnerState({ ...saved, machineId, name, registeredAt: new Date().toISOString() });
177
180
  return { machineId, machineKey: saved.machineKey };
178
181
  }
179
182
 
@@ -281,10 +284,17 @@ async function reconcileOnce(ctx) {
281
284
  }
282
285
  }
283
286
 
287
+ // The signal here lives as long as the runner does, so the abort listener must
288
+ // be removed when the timer wins. Leaving it attached leaked one listener per
289
+ // loop (~4k/day at a 20s interval) and tripped MaxListenersExceededWarning.
284
290
  function sleep(ms, signal) {
285
291
  return new Promise((resolve) => {
286
- const t = setTimeout(resolve, ms);
287
- if (signal) signal.addEventListener('abort', () => { clearTimeout(t); resolve(); }, { once: true });
292
+ const onAbort = () => { clearTimeout(t); resolve(); };
293
+ const t = setTimeout(() => {
294
+ if (signal) signal.removeEventListener('abort', onAbort);
295
+ resolve();
296
+ }, ms);
297
+ if (signal) signal.addEventListener('abort', onAbort, { once: true });
288
298
  });
289
299
  }
290
300