improvement(cron): fire-and-forget for cron-invoked endpoints#4764
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview A new The schedules API contract response drops Reviewed by Cursor Bugbot for commit 82d194c. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cb5b5f4. Configure here.
Greptile SummaryThis PR converts four cron-invoked endpoints (
Confidence Score: 5/5Safe to merge — the fire-and-forget refactor is mechanically correct across all four routes, lock release is guarded by The core pattern (acquire lock synchronously → return 202 → release lock in detached No files require special attention. The only gaps are minor: a missing error-path test in Important Files Changed
Sequence DiagramsequenceDiagram
participant Cron as Cron Caller
participant Handler as Route Handler
participant Redis as Redis (Lock)
participant BG as Background Task
Cron->>Handler: GET (with auth header)
Handler->>Handler: verifyCronAuth()
Handler->>Redis: acquireLock(key, value, TTL)
Redis-->>Handler: true / false
alt Lock already held
Handler-->>Cron: "202 { status: 'skip' }"
else Lock acquired
Handler->>BG: runDetached(label, work)
Note over BG: Runs detached — caller does not await
Handler-->>Cron: "202 { status: 'started' }"
BG->>BG: do work (DB queries, Graph API, polling)
BG->>Redis: releaseLock(key, value) [in finally]
end
Reviews (2): Last reviewed commit: "improvement(cron): drop single-flight gu..." | Re-trigger Greptile |
|
@greptile review |

Summary
schedules/execute, the webhook poll routes,notifications/poll, andrenew-subscriptionsnow ack the cron caller immediately with202and run the work detached in the background, so the caller's request timeout never trips and retries can't pile duplicate runs on the serverlib/core/utils/background.ts(runDetached); extractedrunScheduleTickfrom the schedule route;renew-subscriptionsgained a Redis lock (it had none)FOR UPDATE SKIP LOCKEDrow claiming (+ advisory locks in DB-fallback mode); no in-process guard needed. Poll/notifications keep their existing Redis lock, with release moved into the detachedfinallyType of Change
Testing
Tested manually.
bun run lint,bun run check:api-validation:strict, and unit/route tests across the touched files all pass.Checklist