mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-11 21:41:36 +00:00
fix(app): recover state after sse reconnect and harden sse streams (#13973)
This commit is contained in:
parent
07947bab7d
commit
3dfbb70593
6 changed files with 75 additions and 6 deletions
|
|
@ -66,6 +66,8 @@ export const GlobalRoutes = lazy(() =>
|
|||
}),
|
||||
async (c) => {
|
||||
log.info("global event connected")
|
||||
c.header("X-Accel-Buffering", "no")
|
||||
c.header("X-Content-Type-Options", "nosniff")
|
||||
return streamSSE(c, async (stream) => {
|
||||
stream.writeSSE({
|
||||
data: JSON.stringify({
|
||||
|
|
@ -82,7 +84,7 @@ export const GlobalRoutes = lazy(() =>
|
|||
}
|
||||
GlobalBus.on("event", handler)
|
||||
|
||||
// Send heartbeat every 30s to prevent WKWebView timeout (60s default)
|
||||
// Send heartbeat every 10s to prevent stalled proxy streams.
|
||||
const heartbeat = setInterval(() => {
|
||||
stream.writeSSE({
|
||||
data: JSON.stringify({
|
||||
|
|
@ -92,7 +94,7 @@ export const GlobalRoutes = lazy(() =>
|
|||
},
|
||||
}),
|
||||
})
|
||||
}, 30000)
|
||||
}, 10_000)
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
stream.onAbort(() => {
|
||||
|
|
|
|||
|
|
@ -501,6 +501,8 @@ export namespace Server {
|
|||
}),
|
||||
async (c) => {
|
||||
log.info("event connected")
|
||||
c.header("X-Accel-Buffering", "no")
|
||||
c.header("X-Content-Type-Options", "nosniff")
|
||||
return streamSSE(c, async (stream) => {
|
||||
stream.writeSSE({
|
||||
data: JSON.stringify({
|
||||
|
|
@ -517,7 +519,7 @@ export namespace Server {
|
|||
}
|
||||
})
|
||||
|
||||
// Send heartbeat every 30s to prevent WKWebView timeout (60s default)
|
||||
// Send heartbeat every 10s to prevent stalled proxy streams.
|
||||
const heartbeat = setInterval(() => {
|
||||
stream.writeSSE({
|
||||
data: JSON.stringify({
|
||||
|
|
@ -525,7 +527,7 @@ export namespace Server {
|
|||
properties: {},
|
||||
}),
|
||||
})
|
||||
}, 30000)
|
||||
}, 10_000)
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
stream.onAbort(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue