Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: watchdog re-entry guard + ImageGen Manage link uses Router Link

Adam Eivye79b9d42fc59
diff --git a/client/src/pages/ImageGen.jsx b/client/src/pages/ImageGen.jsx
index 8b46ebe0cf..6190164d83 100644
--- a/client/src/pages/ImageGen.jsx
+++ b/client/src/pages/ImageGen.jsx
@@ -830,7 +830,7 @@ export default function ImageGen() {
<label className="block text-xs font-medium text-gray-400">
LoRAs <span className="text-gray-600 font-normal">({compatibleLoras.length}/{availableLoras.length} compatible)</span>
</label>
- <a href="/media/loras" className="text-[11px] text-port-accent hover:underline">Manage →</a>
+ <Link to="/media/loras" className="text-[11px] text-port-accent hover:underline">Manage →</Link>
</div>
{compatibleLoras.length === 0 ? (
<p className="text-xs text-gray-500 italic">No LoRAs match this model's runner. Install one matching <code>{currentRunnerFamily}</code> on the LoRAs page.</p>
diff --git a/server/services/mediaJobQueue/index.js b/server/services/mediaJobQueue/index.js
index d299675674..f86ee96dce 100644
--- a/server/services/mediaJobQueue/index.js
+++ b/server/services/mediaJobQueue/index.js
@@ -540,15 +540,29 @@ async function runJob(job) {
// where a runner emits structured progress without going through
// handleLine (e.g. a future direct emit).
emitter.on('progress', onActivity);
+ // setInterval with an async tick can overlap if the await
+ // (getGenModuleForJob → dynamic import) takes longer than the interval.
+ // Without this guard, two ticks could both pass the post-await
+ // status check and both call mod.cancel() + handlers.failed(). The
+ // terminal sink in terminate() is idempotent, but mod.cancel() being
+ // called twice racing with the SIGKILL escalation is messy. Track an
+ // inFlight flag so only one tick is ever past the await at a time.
+ let watchdogInFlight = false;
watchdogTimer = setInterval(async () => {
+ if (watchdogInFlight) return;
if (job.status !== 'running') return;
const idleFor = Date.now() - lastActivityAt;
if (idleFor < idleTimeoutMs) return;
- const mod = await getGenModuleForJob(job);
- if (job.status !== 'running') return;
- console.log(`⏱️ media-job [${job.id.slice(0, 8)}] watchdog fired after ${idleFor}ms idle (limit ${idleTimeoutMs}ms) — marking failed`);
- if (mod?.cancel) mod.cancel();
- handlers.failed({ error: `watchdog timeout: no runner output for ${Math.round(idleFor / 1000)}s (limit ${Math.round(idleTimeoutMs / 1000)}s)` });
+ watchdogInFlight = true;
+ try {
+ const mod = await getGenModuleForJob(job);
+ if (job.status !== 'running') return;
+ console.log(`⏱️ media-job [${job.id.slice(0, 8)}] watchdog fired after ${idleFor}ms idle (limit ${idleTimeoutMs}ms) — marking failed`);
+ if (mod?.cancel) mod.cancel();
+ handlers.failed({ error: `watchdog timeout: no runner output for ${Math.round(idleFor / 1000)}s (limit ${Math.round(idleTimeoutMs / 1000)}s)` });
+ } finally {
+ watchdogInFlight = false;
+ }
}, Math.min(30_000, Math.max(25, Math.floor(idleTimeoutMs / 4))));
watchdogTimer.unref?.();