fix: summarizeText Cloud SQL secrets + WS cold-start timeout#557
Conversation
summarizeText gained Cloud SQL usage (userRepository/creditService) in the July credit repricing but never declared CLOUD_SQL_SECRETS in its onCall options. The deployed revision therefore had no CLOUD_SQL_* env vars and every call failed 500 with "Missing required Cloud SQL environment variables" before reaching the model. Adds the secrets binding (matching wikiLlm et al.) and a regression test asserting the endpoint manifest carries all four secret bindings. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
First message after idle hit the 5s WS connect timeout while Cloud Run cold-started (~7.5s observed), so every fresh session stalled 5s and fell back to HTTP. Raise the connect timeout to 10s and add a 60s circuit breaker after transport-level failures so WS-blocked networks pay the connect wait once per cooldown window instead of on every message. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Pull request overview
Production fixes to address (1) summarizeText callable failures in prod due to missing Cloud SQL secret bindings and (2) chat WebSocket cold-start/blocked-network first-message timeouts by increasing the connect timeout and adding a retry cooldown to avoid repeated slow WS attempts.
Changes:
- Bind
CLOUD_SQL_SECRETSto thesummarizeTextcallable’sonCalloptions and add a regression test verifying the secret bindings are present in the endpoint manifest. - Increase WebSocket connect timeout to 10s to cover Cloud Run cold starts and add a 60s cooldown after transport-level WS failures to avoid paying the connect wait on every message.
- Add Jest coverage for the WS cooldown behavior and the new 10s connect-timeout fallback behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/services/cloudAgentService.ts | Increase WS connect timeout; add transport-failure cooldown to prefer HTTP after WS connect failures. |
| tests/cloudAgentService.test.ts | Add tests covering WS cooldown behavior and 10s connect-timeout fallback. |
| functions/src/summarizeText.ts | Add Cloud SQL secret bindings to the callable function configuration. |
| functions/src/summarizeText.test.ts | Add regression test asserting the callable endpoint declares all Cloud SQL secret bindings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot review on #557: authTimeout guarded WS open/connect (WS_CONNECT_TIMEOUT_MS), not the separate auth-timeout path ('WebSocket auth timeout' on close code 4001). Renamed to connectTimeout throughout. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
/fix-pr follow-upCommit: Review resolution
Verification
|
Summary
Two production fixes found while investigating chat-screen errors (2026-07-13):
1.
summarizeText500s — missing Cloud SQL secret bindingsEvery prod
summarizeTextcall has been failing withMissing required Cloud SQL environment variables: CLOUD_SQL_CONNECTION_NAME, CLOUD_SQL_DB_USER, CLOUD_SQL_DB_PASS, CLOUD_SQL_DB_NAMEsince the July credit repricing added
userRepository/creditService(Cloud SQL) to the handler without declaringsecrets: [...CLOUD_SQL_SECRETS]in itsonCalloptions — the deployed revision has zeroCLOUD_SQL_*env vars. Client surfaces this asFailed to summarize conversation context: FirebaseError: INTERNAL.wikiLlmet al.)summarizeTexthad the gap2. Chat WebSocket first-message timeouts
First message after idle hit the 5s WS connect timeout while the cloud-agent Cloud Run instance cold-started (~7.5s observed; server logs show the 101 upgrade succeeding after the client gave up). Every fresh session stalled 5s then fell back to HTTP.
Test plan
summarizeTextreturns 200 and first chat message of a fresh session streams over WS🤖 Generated with Claude Code