fix(core): stop refreshing realtime credentials for a socket that never opens - #7421
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: CopilotKit/CopilotKit/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
ChangesRealtime socket retry handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Run sessions now stop retrying after repeated sockets fail to open, while direct connections continue reconnecting. No actionable issue is established that would prevent merging after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-telegram
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/intelligence-langgraph
@copilotkit/intelligence-mastra
@copilotkit/mcp-apps-renderer
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/react-textarea
@copilotkit/react-ui
@copilotkit/runtime
@copilotkit/runtime-client-gql
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
|
Size Change: +748 B (+0.04%) Total Size: 1.74 MB 📦 View Changed
ℹ️ View Unchanged
|
…er opens When the thread socket hit five consecutive errors, IntelligenceAgent fetched fresh join credentials and opened a new socket. Nothing limited that loop. When the realtime endpoint answered 503, every new socket failed the same way, and one chat turn waited about 96 s with nothing shown to the developer. The agent now counts the sessions in a row whose socket never opened. After two refreshes of that kind, the run fails with an error that names the realtime URL and says that the endpoint is unavailable. A session whose socket opened and then dropped resets the count. So a real connection that drops still recovers as before. refs PE-84 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rrectly Review of the previous commit found three problems: - The cap also applied to connect(), which restores history in the background. RunHandler.connectAgent does not retry after it fails, so an outage at page load would lose history until a reload. Before, the connect kept reconnecting until the endpoint recovered. The cap now applies only to streamMode "run", where a developer is waiting on the turn. - The error said "N attempts with fresh credentials", but the first attempt used the original credentials. It now says "N connection attempts". - The socketOpened flag sat outside defer, so a second subscription would share it. It is now per subscription. A new test keeps a connect reconnecting past the cap. It fails when the cap covers connect too. refs PE-84 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
4563b53 to
df1327b
Compare
|
Draft until: one chat turn in a browser against an unavailable realtime endpoint fails in seconds with the new error, instead of hanging.
What does this PR do?
When the thread socket hit five consecutive errors,
IntelligenceAgentfetched fresh join credentials and opened a new socket (observeThread$). Nothing limited that loop. When the realtime endpoint answered 503, every new socket failed the same way. In one onboarding run, a chat turn waited about 96 s with nothing shown to the developer.After this change:
MAX_UNOPENED_CREDENTIAL_REFRESHES), the run fails. The error names the realtime URL and says that the endpoint is unavailable.streamMode: "run"). Aconnect()restores history in the background, andRunHandler.connectAgentdoes not retry it after a failure. So a connect keeps reconnecting until the endpoint recovers, as before.Out of scope, and still open on the ticket: an HTTP fallback for turn events (no HTTP event path exists), a realtime-status signal in the chat UI, and a 5xx monitor on the realtime gateway.
Tests
fails the run with a realtime error when refreshed sockets never open. It timed out before the fix, because the loop never ended. Now it fails after 3 credential fetches with the named error.keeps refreshing credentials when the refreshed socket opened before failing. This guards the reset.keeps reconnecting a connect whose sockets never open. It fails when the cap also covers connect mode.@copilotkit/core: 952 tests passed.check-typespassed.Related PRs and Issues
Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit