@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 +1 -1
- package/src/agent-runtime/runner.js +15 -5
package/package.json
CHANGED
|
@@ -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
|
|
175
|
-
|
|
176
|
-
|
|
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
|
|
287
|
-
|
|
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
|
|