improvement(polling): fix correctness and efficiency across all polling handlers#4067
improvement(polling): fix correctness and efficiency across all polling handlers#4067waleedlatif1 merged 9 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview RSS polling adds conditional GET support ( Reviewed by Cursor Bugbot for commit f82c7f7. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: RSS GUID fallback diverges between tracking and idempotency
- Added the same truthiness guard (item.title && item.pubDate) to the idempotency key computation at line 295-298 to match the tracking and filtering logic.
Or push these changes by commenting:
@cursor push 79c99ddceb
Preview (79c99ddceb)
diff --git a/apps/sim/lib/webhooks/polling/rss.ts b/apps/sim/lib/webhooks/polling/rss.ts
--- a/apps/sim/lib/webhooks/polling/rss.ts
+++ b/apps/sim/lib/webhooks/polling/rss.ts
@@ -292,7 +292,10 @@
for (const item of items) {
try {
- const itemGuid = item.guid || item.link || `${item.title}-${item.pubDate}`
+ const itemGuid =
+ item.guid ||
+ item.link ||
+ (item.title && item.pubDate ? `${item.title}-${item.pubDate}` : '')
await pollingIdempotency.executeWithIdempotency(
'rss',This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Greptile SummaryThis PR overhauls polling correctness and efficiency across Gmail, Outlook, IMAP, and RSS handlers, and removes the trigger.dev dispatch path in favor of direct Redis-locked synchronous polling. Changes include History API pagination for Gmail,
Confidence Score: 4/5Safe to merge for Outlook, IMAP, RSS, and the schedule/route fixes; the Gmail pagination fallback needs a small guard before merging for high-volume inboxes. One P1 issue remains in gmail.ts: a transient server error on History API page 2+ silently discards all messages collected from earlier pages and substitutes a time-windowed search that may not overlap, causing missed emails. All other providers and the scheduling fix look correct. apps/sim/lib/webhooks/polling/gmail.ts — mid-pagination error handling in the do...while loop (lines 181–193)
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/webhooks/poll/[provider]/route.ts | Restructures lock management into a nested try/finally so the lock is always released even on poll errors; removes the legacy trigger.dev dispatch path. releaseLock correctly checks ownership via a Lua script, so the call in the skip-case finally is a confirmed no-op. |
| apps/sim/lib/webhooks/polling/gmail.ts | Adds History API pagination via do...while loop, historyTypes filter, 403/429 hard-throw, and fresh-historyId recovery on empty search fallback. A P1 bug exists: a non-fatal error on page 2+ of pagination discards all previously collected message IDs and falls back to search, risking silent message loss. |
| apps/sim/lib/webhooks/polling/imap.ts | Consolidates to a single ImapFlow connection per poll, adds UIDVALIDITY tracking per mailbox, advances UID in the fetch loop, and fixes messageFlagsAdd range arguments. Clean and correct. |
| apps/sim/lib/webhooks/polling/outlook.ts | Adds @odata.nextLink pagination, decouples page size from total cap, adopts fetchWithRetry for all Graph calls, skips folder filter on partial resolution failure, and removes Content-Type from GET requests. Correct behavior. |
| apps/sim/lib/webhooks/polling/rss.ts | Adds conditional GET (ETag/Last-Modified), 304 handling, raises GUID cap to 500, and skips GUID-less items in processRssItems. A P2 gap: GUID-less items with no isoDate still pass the newItems filter and consume the 25-item cap every poll without being processed. |
| apps/sim/app/api/schedules/execute/route.ts | Converts dynamic await import() inside .map() to a static top-level import, fixing a flaky concurrent-import deadlock. Clean change with no issues. |
Reviews (7): Last reviewed commit: "fix(polling): decouple outlook page size..." | Re-trigger Greptile
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7c7c95d. Configure here.
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
…ng handlers - Gmail: paginate history API, add historyTypes filter, differentiate 403/429, fetch fresh historyId on fallback to break 404 retry loop - Outlook: follow @odata.nextLink pagination, use fetchWithRetry for all Graph calls, fix $top alignment, skip folder filter on partial resolution failure, remove Content-Type from GET requests - RSS: add conditional GET (ETag/If-None-Match), raise GUID cap to 500, fix 304 ETag capture per RFC 9111, align GUID tracking with idempotency fallback key - IMAP: single connection reuse, UIDVALIDITY tracking per mailbox, advance UID only on successful fetch, fix messageFlagsAdd range type, remove cross-mailbox legacy UID fallback - Dispatch polling via trigger.dev task with per-provider concurrency key; fall back to synchronous Redis-locked polling for self-hosted
…dis-locked polling
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f82c7f7. Configure here.

Summary
Type of Change
Testing
Tested manually
Checklist