mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Fix SSE reliability and message delivery for production environments (#85)
* Switch to sync prompt endpoint for reliable message delivery 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. * Add SSE heartbeat to prevent Cloudflare 524 timeout
This commit is contained in:
1 parent
d78bb120ed
commit
a05535e0ef
6 files changed
+61
-10
No files matched your search
@@ -3,6 +3,9 @@ import { stream } from 'hono/streaming'
|
||||
import { sseAggregator } from '../services/sse-aggregator'
|
||||
import { SSESubscribeSchema } from '@opencode-manager/shared/schemas'
|
||||
import { logger } from '../utils/logger'
|
||||
import { DEFAULTS } from '@opencode-manager/shared/config'
|
||||
|
||||
const { HEARTBEAT_INTERVAL_MS } = DEFAULTS.SSE
|
||||
|
||||
export function createSSERoutes() {
|
||||
const app = new Hono()
|
||||
@@ -36,7 +39,16 @@ export function createSSERoutes() {
|
||||
directories
|
||||
)
|
||||
|
||||
const heartbeatInterval = setInterval(() => {
|
||||
try {
|
||||
writeSSE('heartbeat', JSON.stringify({ timestamp: Date.now() }))
|
||||
} catch {
|
||||
clearInterval(heartbeatInterval)
|
||||
}
|
||||
}, HEARTBEAT_INTERVAL_MS)
|
||||
|
||||
writer.onAbort(() => {
|
||||
clearInterval(heartbeatInterval)
|
||||
cleanup()
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user