Chris
Chris
HHono
Created by Chris on 8/30/2024 in #help
Hono SSE Stream Closing Unexpectedly After 10 Seconds
Title: Hono SSE Stream Closing After 10 Seconds Issue: Using Hono's streamSSE, the SSE connection closes after ~10 seconds, regardless of client (curl/browser). A minimal Node.js SSE server works fine. Environment: Debian, localhost Code snippet:
app.get("/render", (c: Context) => {
return streamSSE(c, async (stream) => {
while (true) {
await stream.writeSSE({
data: `It is ${new Date().toISOString()}`,
event: "time-update",
});
await stream.sleep(1000);
}
});
});
app.get("/render", (c: Context) => {
return streamSSE(c, async (stream) => {
while (true) {
await stream.writeSSE({
data: `It is ${new Date().toISOString()}`,
event: "time-update",
});
await stream.sleep(1000);
}
});
});
Logs show:
SSE connection initiated
Sending message #1: It is 2024-08-30T14:21:10.214Z
...
Sending message #9: It is 2024-08-30T14:21:18.236Z
Stream aborted by client
SSE connection initiated
Sending message #1: It is 2024-08-30T14:21:10.214Z
...
Sending message #9: It is 2024-08-30T14:21:18.236Z
Stream aborted by client
Any ideas why Hono's SSE implementation might be closing the connection prematurely? Tried error handling and abort detection, issue persists. Thanks for any help!
16 replies