Skip to content

fix: offload token persistence during async Google token refresh - #8378

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/offload-google-token-firestore-write
Jun 26, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/offload-google-token-firestore-write

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

Summary

The async refresh_google_token coroutine persisted the new access token via users_db.set_integration() — a synchronous Firestore write — directly on the event loop. When a Gmail request hit an expired token, the refresh path blocked concurrent chat/tool streaming until Firestore returned.

Wrap the Firestore write with await run_blocking(db_executor, ...) so it runs in the DB thread pool, consistent with backend async I/O rules (AGENTS.md: "never call sync DB/storage/file functions directly inside async def").

This was originally flagged as P2 by Codex review on PR #8364 (retry_on_auth_async), but the fix targets google_utils.py which was not part of that PR's diff. Opening as a standalone fix.

Test Plan

  • scan_async_blockers.py reports zero blocking calls for refresh_google_token
  • Pre-commit formatting passes (black)
  • CI Hermetic Backend E2E passes

Review in cubic

The refresh_google_token coroutine persisted the new access token via
users_db.set_integration() — a synchronous Firestore write — directly on
the event loop. When a Gmail request hit an expired token, the refresh
path blocked concurrent chat/tool streaming until Firestore returned.

Wrap the Firestore write with run_blocking(db_executor, ...) so it runs
in the DB thread pool, consistent with backend async I/O rules.

Verification: scan_async_blockers reports zero blocking calls for the
function.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

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

Re-trigger cubic

@Git-on-my-level
Git-on-my-level merged commit 52a1782 into main Jun 26, 2026
4 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/offload-google-token-firestore-write branch June 26, 2026 02:57
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