Skip to content

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

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-9b54
Draft

fix(sidecar): resume truncated Gmail history via page token (#595)#642
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-9b54

Conversation

@cursor

@cursor cursor Bot commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • Persist history_page_token (migration 32) when a Gmail history listing hits MAX_HISTORY_PAGES and the current 3-page slice is fully worked
  • Resume listing from the saved nextPageToken on the next poll without advancing history_cursor
  • Clear the token on a complete listing or when a batch cap leaves unprocessed ids in the current slice

Why

listNewMessageIds caps at 3 history pages. When truncated, 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. This is a data-loss bug in the Workspace sidecar poller.

Test plan

  • npm test -- tests/providers/workspace-poll.test.ts tests/providers/gmail-client.test.ts test/durableObject/sidecar-state.test.ts passes (59 tests)
  • New test covers the deadlock scenario: all-deduped pages save page token, next poll resumes and advances cursor

Notes for reviewer

Cherry-picked from prior investigation branch cursor/critical-bug-investigation-9ee7. Batch-cap mid-slice intentionally clears the page token so unprocessed ids in pages 1–3 of the same cursor are not skipped.

Open in Web View Automation 

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>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 22, 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 6919afd Commit Preview URL

Branch Preview URL
Jul 22 2026, 11:03 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 22, 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 6919afd Jul 22 2026, 11:04 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