fix(v2): await handleRecurrence so the DB isn't closed mid-flight

sweepSession called handleRecurrence without await, then synchronously
closed inDb in its finally block. handleRecurrence is async because it
does a dynamic `import('cron-parser')` before the first DB write; that
import resolved after the finally had already run, so insertRecurrence
hit a closed handle and threw "The database connection is not open".

Net effect: every recurring task was correctly marked completed by
syncProcessingAcks, but its next occurrence never got scheduled.
Single-word fix — `await`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
exe.dev user
2026-04-16 14:58:01 +00:00
committed by Daniel
parent 9617087c16
commit 4c46dd3b39

View File

@@ -101,7 +101,7 @@ async function sweepSession(session: Session): Promise<void> {
}
// 4. Handle recurrence for completed messages
handleRecurrence(inDb, session);
await handleRecurrence(inDb, session);
} finally {
inDb.close();
outDb?.close();