Skip to content

fix(gmail): clear the history cursor only from a poll that held one - #9364

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/gmail-cursor-clear-only-when-rejected
Oct 24, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
fix/gmail-cursor-clear-only-when-rejected

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up to fix(gmail): drop an expired history cursor instead of re-saving it every poll #9343. A search-mode Gmail poll (no stored cursor) sent historyId: undefined, which updateWebhookProviderConfig treats as a key removal. If it overlapped a newer poll that had just stored a cursor, it deleted that cursor.
  • The poll state is now built once and carries historyId only when this poll started with a cursor or found one, so only a poll whose cursor Gmail rejected can clear it. Search-mode polls leave the key alone, as before fix(gmail): drop an expired history cursor instead of re-saving it every poll #9343.
  • Left as is: a poll holding an expired cursor can still clear a cursor an overlapping poll stored, the same stale-snapshot last-writer-wins race every polling provider already has. It needs an overlap (the provider lock outliving its TTL, or no Redis) plus an expired cursor, and costs at most an extra search-mode poll — the webhookId:messageId idempotency key dedupes, and the search window covers the gap. A compare-and-set would change updateWebhookProviderConfig for every provider.

Type of Change

  • Bug fix

Testing

  • lib/webhooks/polling/gmail.test.ts: new case "leaves the stored cursor untouched when a search-mode poll finds no mail" fails on staging (sends a historyId key) and passes with the fix
  • lib/webhooks/polling/ suite: 57 passed
  • biome, check:test-patterns, check:comment-hygiene

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

A search-mode poll (no stored cursor) sent historyId: undefined, which updateWebhookProviderConfig treats as a key removal. If it overlapped a newer poll that had just stored a cursor, it deleted that cursor. The poll state is now built once and carries historyId only when this poll started with a cursor or found one, so only a poll whose cursor Gmail rejected can clear it.
@vercel

vercel Bot commented Oct 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 24, 2026 6:34pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Gmail polls now share one pollState update. They include historyId only when the poll started with a cursor or found one.

  • Search-mode Gmail polls leave a saved history cursor alone.

No actionable issues found. Tests were inspected, not run.

Reviews (1) · Last reviewed commit: "fix(gmail): clear the history cursor onl..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 3fc79a2 into staging Oct 24, 2026
68 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/gmail-cursor-clear-only-when-rejected branch October 24, 2026 19:04

This branch was previously deployed

1 inactive deployment
Preview — b7247c49 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant