-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: chat stuck issue #5274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: chat stuck issue #5274
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate Unit Tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Chat Stuck Due to Error Handling Gaps
The onComplete callback, intended to ensure notifyMessageComplete is always called to unstick the chat, has two error handling deficiencies:
- It lacks a
try-catchforgetRoom()andgetWorld()calls, meaningnotifyMessageCompletewon't be called if they throw. - The
onCompletecallback itself is not invoked if theemitEventcall fails.
Both scenarios can leave the chat in a "thinking" state.
packages/server/src/services/message.ts#L474-L487
eliza/packages/server/src/services/message.ts
Lines 474 to 487 in b289348
| await this.runtime.emitEvent(EventType.MESSAGE_RECEIVED, { | |
| runtime: this.runtime, | |
| message: agentMemory, | |
| callback: callbackForCentralBus, | |
| onComplete: async () => { | |
| const room = await this.runtime.getRoom(agentRoomId); | |
| const world = await this.runtime.getWorld(agentWorldId); | |
| const channelId = room?.channelId as UUID; | |
| const serverId = world?.serverId as UUID; | |
| await this.notifyMessageComplete(channelId, serverId); | |
| } | |
| }); |
Was this report helpful? Give feedback by reacting with 👍 or 👎
I encountered an issue where, if the chat failed (e.g., the useModel function exceeded the rate limit), an error would be shown but the chat would get stuck displaying "agent is thinking." In this state, the user could no longer type unless they refreshed the page.
This PR fixes the issue by calling the notifyMessageComplete function inside the onComplete handler of emitEvent