Skip to content

fix(sidecar): resume truncated Gmail history via page token (#595) - #647

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-e1d5
Draft

fix(sidecar): resume truncated Gmail history via page token (#595)#647
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-bug-investigation-e1d5

Conversation

@cursor

@cursor cursor Bot commented Jul 24, 2026

Copy link
Copy Markdown

Bug and impact

When the Workspace sidecar poller hits the MAX_HISTORY_PAGES=3 cap, listNewMessageIds correctly sets truncated: true and the cursor stays frozen. However, if pages 1–3 are already deduped on every poll, the poller re-fetches the same three pages forever and never reaches page 4+. Mail on later history pages is silently skipped — a data-loss bug for high-volume sidecar mailboxes.

Root cause

Cursor advancement requires !hitCap && !history.truncated, but there was no mechanism to resume pagination within the same startHistoryId after a truncated slice was fully worked (all ids deduped or processed).

Fix

  • Add history_page_token column (migration 32) to persist the dangling nextPageToken once a truncated slice is fully worked.
  • Resume listNewMessageIds from the saved token on the next poll with the same cursor.
  • Clear the token on complete listing, batch-cap mid-slice (restart from page 1), or history-gap re-anchor.
  • Return nextPageToken from listNewMessageIds when truncated.

Validation

Open in Web View Automation 

cursoragent and others added 2 commits July 24, 2026 11:03
When listNewMessageIds hits MAX_HISTORY_PAGES the cursor correctly stays
frozen, but if pages 1-3 are already deduped the poller re-fetched them
forever and never reached page 4+ — silently skipping new mail.

Persist history_page_token (migration 32) once a truncated slice is fully
worked; the next poll resumes from that nextPageToken with the same cursor.
Clear the token on a complete listing or when a batch cap leaves unprocessed
ids in the current slice.

Co-authored-by: schmug <schmug@users.noreply.github.com>
Co-authored-by: schmug <schmug@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ais-hub aa76654 Commit Preview URL

Branch Preview URL
Jul 24 2026, 11:10 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
agentic-inbox aa76654 Jul 24 2026, 11:12 AM

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