Problem
durably_runs records accumulate indefinitely. While individual records are small, over time (e.g., hourly cron jobs running for months) the table grows unbounded. Currently, the only way to remove old runs is manually calling deleteRun().
This is separate from step data cleanup (#87, cleanupSteps option) — step output is the large data and is now cleaned up automatically. Run records are lightweight but should still have an optional retention policy.
Proposal
const durably = createDurably({
dialect,
// Auto-delete terminal runs older than 30 days
retainRuns: '30d',
})
- Only deletes runs in terminal states (
completed, failed, cancelled)
- Runs in
pending or running are never auto-deleted
- Cleanup runs periodically (e.g., once per polling cycle or on a separate interval)
- Default: no retention (keep all runs, backward compatible)
Alternatives
- Explicit purge API:
await durably.purgeRuns({ olderThan: '30d', status: ['completed'] }) — useful as a manual escape hatch regardless of whether auto-purge is implemented
- Both:
retainRuns for automatic + purgeRuns() for manual control
Context
Problem
durably_runsrecords accumulate indefinitely. While individual records are small, over time (e.g., hourly cron jobs running for months) the table grows unbounded. Currently, the only way to remove old runs is manually callingdeleteRun().This is separate from step data cleanup (#87,
cleanupStepsoption) — step output is the large data and is now cleaned up automatically. Run records are lightweight but should still have an optional retention policy.Proposal
completed,failed,cancelled)pendingorrunningare never auto-deletedAlternatives
await durably.purgeRuns({ olderThan: '30d', status: ['completed'] })— useful as a manual escape hatch regardless of whether auto-purge is implementedretainRunsfor automatic +purgeRuns()for manual controlContext