fix(app): recover state after sse reconnect and harden sse streams (#13973)

This commit is contained in:
Shoubhit Dash
2026-02-17 18:40:39 +05:30
committed by GitHub
parent 07947bab7d
commit 3dfbb70593
6 changed files with 75 additions and 6 deletions

View File

@@ -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(() => {

View File

@@ -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(() => {