Recover interrupted runs and requests at boot
A task_run still marked running at startup has no executor - the single-instance app that owned it is gone - yet nothing failed it, the queue worker only claims queued rows, and the heartbeat excludes tasks with a running run, so one interrupted shutdown wedged the company forever. Boot now fails orphaned running runs and their in-flight foreground provider requests (auditably), which hands the task back to the heartbeat for an automatic retry. Background provider requests are untouched; the background worker resumes those by external id.
This commit is contained in:
1 parent
4e47da4d6b
commit
f15ed8cb6f
3 files changed
+129
No files matched your search
@@ -5,6 +5,7 @@ import { DatabaseConnection } from "./database/connection";
|
||||
import { createMainWindow } from "./app/create-window";
|
||||
import { registerIpcHandlers } from "./app/ipc-handlers";
|
||||
import { startProviderBackgroundWorker } from "./app/provider-background-worker";
|
||||
import { recoverInterruptedWork } from "./app/startup-recovery";
|
||||
import { startTaskQueueWorker } from "./app/task-queue-worker";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
@@ -17,6 +18,7 @@ if (!hasSingleInstanceLock) {
|
||||
app.whenReady().then(() => {
|
||||
const profileDir = process.env.AGENTCOMPANY_NEW_PROFILE_DIR ?? join(app.getPath("userData"), "profile");
|
||||
const connection = new DatabaseConnection(join(profileDir, "agentcompany.db"));
|
||||
connection.transaction(() => recoverInterruptedWork(connection.db));
|
||||
const win = createMainWindow({
|
||||
preloadPath: join(__dirname, "../preload/index.js"),
|
||||
rendererDist: join(__dirname, "../renderer"),
|
||||
|
||||
Reference in new issue
Block a user