Streaming not working with Hono Node Server #4154
Streaming doesn't work. it send the response once it's done processing fully. i tried with the bun dev (not bun server) but somehow it seemed working, really strange.
We can run this repo locally: https://github.com/nilooy/my-better-t-app-2 to reproduce it.
the suspected code is here: https://github.com/nilooy/my-better-t-app-2/blob/main/apps/server/src/index.ts#L42-L60
app.post("/ai", async (c) => {
const body = await c.req.json();
const messages = body.messages || [];
const result = streamText({
model: openai("o3-mini"),
messages,
});
for await (const chunk of result.toDataStream()) {
console.log(chunk);
}
c.header("X-Vercel-AI-Data-Stream", "v1");
c.header("Content-Type", "text/plain; charset=utf-8");
return stream(c, (stream) => stream.pipe(result.toDataStream()));
});
VIDEO: https://github.com/user-attachments/assets/c40d44c1-0cac-45f1-983b-0e9fc95cb018
GITHUB ISSUE**: https://github.com/honojs/hono/issues/4154
What version of Hono are you using?
^4.7.10
What runtime/platform is your app running on? (with version if possible)
Node.jsGitHub
GitHub - nilooy/my-better-t-app-2
Contribute to nilooy/my-better-t-app-2 development by creating an account on GitHub.
GitHub
Streaming not working with Hono Node Server · Issue #4154 · honoj...
What version of Hono are you using? ^4.7.10 What runtime/platform is your app running on? (with version if possible) Node.js What steps can reproduce the bug? Streaming doesn't work. it send th...
GitHub
my-better-t-app-2/apps/server/src/index.ts at main · nilooy/my-bet...
Contribute to nilooy/my-better-t-app-2 development by creating an account on GitHub.
3 Replies
what happens if you remove this?
if i understand correctly, when you run the project with turbopack, it awaits + delivers the whole stream at once (or at least that's how it seems)
but when you run the backend and frontend separately (with vite), it streams the way you'd expect
is that correct?
same issue
it's my first time trying Hono.js for a new project but the deadline is tight to explore a new library, at the end i went with the one i know better.
fair enough