Skip to content

fix: Fix chat freezing when messages contain special characters or network errors occur #4843

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

Closed

Conversation

naaa760
Copy link

@naaa760 naaa760 commented Jul 11, 2025

🐛 Problem

Users reported that the chat interface would freeze after submitting messages, especially with messages containing special characters (like Polish text). The UI would become unresponsive even though the backend was processing correctly.

#4841

Solution

Fixed EventSource error handling that was causing the chat to freeze:

  • Removed error throwing** in EventSource onerror handler that was breaking the UI
  • Added safe error property access** to prevent crashes when error objects don't have expected structure
  • Enhanced connection validation** to handle failed EventSource connections gracefully
  • Protected JSON parsing** to prevent single malformed messages from breaking the entire chat
  • Added connection-level error handling** with user-friendly fallback messages

✅ Testing

  • Chat no longer freezes with special character messages
  • Error scenarios are handled gracefully with proper user feedback
  • Build passes without errors
  • Existing functionality preserved

Impact

  • Better user experience with stable chat interface
  • Improved error handling and debugging
  • More resilient to network issues and server errors

@naaa760 naaa760 changed the title fix: Fixchat freezing when messages contain special characters or network errors occur fix: Fix chat freezing when messages contain special characters or network errors occur Jul 11, 2025
closeResponse()
},
async onerror(err) {
console.error('EventSource Error: ', err)
Copy link
Contributor

Choose a reason for hiding this comment

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

we have to throw error here otherwise fetchEventSource will keep retrying non stop causing unlimited calls to the LLM.

previously this had caught us surprised with LLM bills up to thousands due to not throwing the error

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for the help! however I dont think that's the cause to the issue

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.

2 participants