Skip to content

fix(storage): bound Google Drive token refresh lease retries - #4877

Open
AksharP5 wants to merge 1 commit into
CapSoftware:mainfrom
AksharP5:gdrive-lease-bound
Open

AksharP5 wants to merge 1 commit into
CapSoftware:mainfrom
AksharP5:gdrive-lease-bound

Conversation

@AksharP5

@AksharP5 AksharP5 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4875

If a Google Drive token refresh could not claim the persisted refresh lease and no fresh cached token appeared (for instance after an integration row was removed), refreshGoogleDriveAccessToken recursed indefinitely after every lease wait instead of failing.

Bound the lease retry to one follow-up claim attempt after waiting out a peer's lease, failing with Storage.StorageError if the lease still cannot be acquired and no cached token was stored. A normal peer lease expiry still succeeds on the second attempt.

Before / After

Scenario Before After
claimRefreshLease always returns false and cache stays empty across 125s (TestClock) Fiber never terminates (infinite retry loop) Fails cleanly with Storage.StorageError after 2 lease claim attempts
Peer lease expires before second claim attempt Succeeds on second attempt Still succeeds on second attempt (fresh-token)

Verification

  • bun run --cwd apps/web vitest run __tests__/unit/google-drive-storage.test.ts (90/90 passed, including both lease retry tests)
  • bun run biome check packages/web-backend/src/Storage/GoogleDrive.ts apps/web/__tests__/unit/google-drive-storage.test.ts
  • node scripts/test-lint/run.mjs

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge.

Summary

Bounds Google Drive token refresh to two lease claims instead of retrying forever.

  • Google Drive token refreshes make at most two lease claims.

Reviews (1) · Last reviewed commit: "fix(storage): bound Google Drive token r..." · Reviewed by Greptile

@vercel

vercel Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

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

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Dec 4, 2026 5:11pm UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status December 4, 2026 17:11 Inactive

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 1992e17e Deployed Dec 4, 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.

Google Drive token refresh loops indefinitely when a refresh lease cannot be claimed

1 participant