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:
Logs show:
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!12 Replies
Which runtime are you using? I tried with Nodejs, seems to be working for me
I am using bun as runtime
Do you think this could be an issue?
Maybe, try changing the runtime to nodejs for checking this 🧪 , and if the problem is resolved, try searching the bun docs or ask a question regarding this on their discord
https://discord.com/channels/1011308539819597844/1011308539819597847/1277621456586670203
I had this issue since version 1.1.26 of bun.... this is a nasty setting to change in a patch
Thank you so much! You saved us a lot of time. How did you solve this issue or better what do you reccomend to to? Should we just downgrade our version and wait till hono fixes their serve or is that something we need to configure by our own?
I increased the value of
idleTimeout
Is setting the idleTimeout: 0, the same as setting it to inf? Or would you reccomend using a real value and actually making use of the feature
Yes it is. But I only use bun to dev, in prod we use node.js so this value is only use locally, but I agree that you should probably set it to another value if you use bun in production
Are there any reasons for your prof/dev setup? Did you choose node.js for prod because of stability? We're running bun in both dev and prod but often debate if node is a more mature and stable option. So far bun did a good job but more recently we are facing more and more issues
Honestly, I just node.js because I'm more familiar with it and was easier for me to work with Node.js, however due to some monorepo, bundling and typescript setup running our server locally on our laptop became a pain in the a** (tsx, ts-run, you name it always failed at some point), I decided to try bun to run TS natively and it worked amazingly so far.
thanks so much for this, just spent a few hours trying to fix it
Fixed: Default idleTimeout no longer set in node:http In Bun 1.1.26, the default idleTimeout was 10 seconds, which was a breaking change as versions before had unlimited timeout. The default value of idleTimeout is now 0, which disables the timeout.https://bun.sh/blog/bun-v1.1.27#fixed-default-idletimeout-no-longer-set-in-node-http
Bun
Bun v1.1.27
Fixes 130 bugs (addressing 250 👍).
bun pm pack
, faster node:zlib
. Static routes in Bun.serve(). ReadableStream support in response.clone() & request.clone(). Per-request timeouts. Cancel method in ReadableStream is called. bun run
handles CTRL + C better. Faster buffered streams. bun outdated
package filtering. Watch arbtirary file types...