Fix SSE reliability and message delivery for production environments#85
Merged
chriswritescode-dev merged 2 commits intomainfrom Jan 27, 2026
Merged
Fix SSE reliability and message delivery for production environments#85chriswritescode-dev merged 2 commits intomainfrom
chriswritescode-dev merged 2 commits intomainfrom
Conversation
Use the synchronous /message endpoint instead of /prompt_async to ensure the UI receives authoritative response data. This matches OpenCode TUI behavior and prevents message desync during sub-agent tasks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses SSE connection reliability issues, particularly for deployments behind Cloudflare or similar proxies that terminate idle connections. It also switches to synchronous message delivery to prevent message desync during complex operations.
Changes
Backend:
Frontend:
/prompt_asyncto synchronous/messageendpoint for reliable message deliveryShared:
HEARTBEAT_INTERVAL_MSconstant (60000ms) to SSE defaultsWhy These Changes
Cloudflare 524 Timeout: Without regular activity, Cloudflare terminates connections after ~100 seconds of inactivity. The heartbeat prevents this.
Message Desync: Using the async endpoint could cause the UI to miss authoritative response data, especially during sub-agent tasks. The sync endpoint matches OpenCode TUI behavior and returns the confirmed message.
Race Conditions: Proper query cancellation before optimistic updates prevents React Query race conditions.