nilooy
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.js8 replies