@yemi33/minions 0.1.494 → 0.1.495
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/CHANGELOG.md +2 -1
- package/engine/shared.js +54 -33
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.1.
|
|
3
|
+
## 0.1.495 (2026-04-07)
|
|
4
4
|
|
|
5
5
|
### Fixes
|
|
6
|
+
- lock timeout retry with backoff to prevent tick cascade failures (#389)
|
|
6
7
|
- GitHub PR poll backoff for inaccessible repos (closes #377) (#386)
|
|
7
8
|
- reconcile agent completions during engine downtime (closes #376) (#385)
|
|
8
9
|
- settings button shows modal immediately with loading state
|
package/engine/shared.js
CHANGED
|
@@ -174,51 +174,70 @@ const LOCK_STALE_MS = 60000; // 60 seconds — force-remove locks older than thi
|
|
|
174
174
|
|
|
175
175
|
function withFileLock(lockPath, fn, {
|
|
176
176
|
timeoutMs = 5000,
|
|
177
|
-
retryDelayMs = 25
|
|
177
|
+
retryDelayMs = 25,
|
|
178
|
+
retries = 0,
|
|
179
|
+
retryBackoffMs = 1000
|
|
178
180
|
} = {}) {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
181
|
+
let lastErr = null;
|
|
182
|
+
const maxAttempts = 1 + Math.max(0, retries);
|
|
183
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
184
|
+
if (attempt > 0) {
|
|
185
|
+
// Exponential backoff between retry attempts: retryBackoffMs * 2^(attempt-1)
|
|
186
|
+
const backoff = retryBackoffMs * Math.pow(2, attempt - 1);
|
|
187
|
+
sleepMs(backoff);
|
|
188
|
+
}
|
|
189
|
+
const start = Date.now();
|
|
190
|
+
let fd = null;
|
|
191
|
+
while (Date.now() - start < timeoutMs) {
|
|
190
192
|
try {
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
const dir = path.dirname(lockPath);
|
|
194
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
195
|
+
fd = fs.openSync(lockPath, 'wx');
|
|
196
|
+
break;
|
|
197
|
+
} catch (err) {
|
|
198
|
+
if (err.code !== 'EEXIST') throw err;
|
|
199
|
+
// Check for stale lock — if lock file is older than LOCK_STALE_MS, force-remove it
|
|
200
|
+
try {
|
|
201
|
+
const stat = fs.statSync(lockPath);
|
|
202
|
+
if (Date.now() - stat.mtimeMs > LOCK_STALE_MS) {
|
|
203
|
+
try {
|
|
204
|
+
fs.unlinkSync(lockPath);
|
|
205
|
+
} catch (unlinkErr) {
|
|
206
|
+
// ENOENT: another process deleted the lock between stat and unlink — safe to retry
|
|
207
|
+
if (unlinkErr.code !== 'ENOENT') throw unlinkErr;
|
|
208
|
+
}
|
|
209
|
+
continue; // lock just removed — retry immediately
|
|
198
210
|
}
|
|
199
|
-
|
|
211
|
+
} catch (staleErr) {
|
|
212
|
+
// ENOENT from statSync: lock file disappeared between EEXIST and stat — retry will succeed
|
|
213
|
+
if (staleErr.code !== 'ENOENT') throw staleErr;
|
|
200
214
|
}
|
|
201
|
-
|
|
202
|
-
// ENOENT from statSync: lock file disappeared between EEXIST and stat — retry will succeed
|
|
203
|
-
if (staleErr.code !== 'ENOENT') throw staleErr;
|
|
215
|
+
sleepMs(retryDelayMs);
|
|
204
216
|
}
|
|
205
|
-
sleepMs(retryDelayMs);
|
|
206
217
|
}
|
|
207
|
-
|
|
208
|
-
|
|
218
|
+
if (fd === null) {
|
|
219
|
+
lastErr = new Error(`Lock timeout: ${lockPath}`);
|
|
220
|
+
continue; // retry if attempts remain
|
|
221
|
+
}
|
|
209
222
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
223
|
+
try {
|
|
224
|
+
return fn();
|
|
225
|
+
} finally {
|
|
226
|
+
try { fs.closeSync(fd); } catch { /* cleanup */ }
|
|
227
|
+
try { fs.unlinkSync(lockPath); } catch { /* cleanup */ }
|
|
228
|
+
}
|
|
215
229
|
}
|
|
230
|
+
throw lastErr;
|
|
216
231
|
}
|
|
217
232
|
|
|
218
233
|
function mutateJsonFileLocked(filePath, mutateFn, {
|
|
219
|
-
defaultValue = {}
|
|
234
|
+
defaultValue = {},
|
|
235
|
+
lockRetries,
|
|
236
|
+
lockRetryBackoffMs
|
|
220
237
|
} = {}) {
|
|
221
238
|
const lockPath = `${filePath}.lock`;
|
|
239
|
+
const retries = lockRetries ?? ENGINE_DEFAULTS.lockRetries;
|
|
240
|
+
const retryBackoffMs = lockRetryBackoffMs ?? ENGINE_DEFAULTS.lockRetryBackoffMs;
|
|
222
241
|
return withFileLock(lockPath, () => {
|
|
223
242
|
let data = safeJson(filePath);
|
|
224
243
|
if (data === null || typeof data !== 'object') data = Array.isArray(defaultValue) ? [...defaultValue] : { ...defaultValue };
|
|
@@ -229,7 +248,7 @@ function mutateJsonFileLocked(filePath, mutateFn, {
|
|
|
229
248
|
const finalData = next === undefined ? data : next;
|
|
230
249
|
safeWrite(filePath, finalData);
|
|
231
250
|
return finalData;
|
|
232
|
-
});
|
|
251
|
+
}, { retries, retryBackoffMs });
|
|
233
252
|
}
|
|
234
253
|
|
|
235
254
|
/**
|
|
@@ -479,6 +498,8 @@ const ENGINE_DEFAULTS = {
|
|
|
479
498
|
versionCheckInterval: 3600000, // 1 hour — how often to check npm for updates (ms)
|
|
480
499
|
logFlushInterval: 5000, // 5s — how often to flush buffered log entries to disk
|
|
481
500
|
logBufferSize: 50, // flush immediately when buffer exceeds this many entries
|
|
501
|
+
lockRetries: 2, // retry lock acquisition this many times after initial timeout (total attempts = 1 + lockRetries)
|
|
502
|
+
lockRetryBackoffMs: 500, // base backoff between lock retries (doubles each attempt: 500ms, 1s, 2s, ...)
|
|
482
503
|
};
|
|
483
504
|
|
|
484
505
|
// ─── Status & Type Constants ─────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yemi33/minions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.495",
|
|
4
4
|
"description": "Multi-agent AI dev team that runs from ~/.minions/ — five autonomous agents share a single engine, dashboard, and knowledge base",
|
|
5
5
|
"bin": {
|
|
6
6
|
"minions": "bin/minions.js"
|