Skip to content

fix(sidecar): persist history page token to unblock truncated Gmail history - #684

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-ba62
Closed

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

Conversation

@cursor

@cursor cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

Summary

  • Persist Gmail history.list nextPageToken in sidecar_state when the 3-page cap truncates a history listing
  • Resume pagination from the saved token on the next poll instead of restarting at page 1
  • Clear the token when listing completes or on history-gap re-anchor (migration 32)

Why

When listNewMessageIds hits MAX_HISTORY_PAGES=3 with more pages pending, the poller correctly froze history_cursor but restarted pagination at page 1 on every subsequent poll. Once pages 1–3 were fully deduped the cursor could never advance and mail on page 4+ was permanently lost during bursts.

Test plan

  • npm test passes locally (workspace-poll, gmail-client, sidecar-state — 60 tests)
  • Regression test: two-poll convergence when pages 1–3 are deduped and page 4+ holds new mail
  • gmail-client test covers resumePageToken return on truncated listing

Notes for reviewer

Cherry-pick of validated fix from prior investigation branch (cursor/critical-bug-investigation-4df5). Same root cause flagged in multiple prior scans but never merged to main.

Open in Web View Automation 

…istory

When listNewMessageIds hits the 3-page cap with more pages pending, the
poller froze history_cursor but restarted pagination at page 1 on every
subsequent poll. Once pages 1-3 were fully deduped the cursor could never
advance and mail on page 4+ was permanently lost.

Persist the dangling nextPageToken in sidecar_state (migration 32) and
resume from it on the next poll. Clear the token when the listing completes
or on history-gap re-anchor.

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

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 533538a Commit Preview URL

Branch Preview URL
Aug 12 2026, 11:07 AM

@cloudflare-workers-and-pages

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 533538a Aug 12 2026, 11:08 AM

@schmug

schmug commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Closing as superseded by #686.

This is one of 24 near-identical PRs re-filed daily by an automation that has since been fixed. #686 carries the same Gmail history page-token change and is the one kept open, so no work is lost here.

@schmug schmug closed this Aug 23, 2026
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.

2 participants