reko
reko
HHono
Created by reko on 5/14/2025 in #help
How to wait for streamSse to finish?
I can create a small repro anyways if you want to fiddle around.
13 replies
HHono
Created by reko on 5/14/2025 in #help
How to wait for streamSse to finish?
But I was hoping my middleware wouldn't have to care abou whether its dealing with streaming or regular requessts
13 replies
HHono
Created by reko on 5/14/2025 in #help
How to wait for streamSse to finish?
I guess what I can do as a work-around is use deferred promise pattern and put a promise in the request context and then await for that to finish in the middleware.
13 replies
HHono
Created by reko on 5/14/2025 in #help
How to wait for streamSse to finish?
Yeah so I tried this:
const response = await new Promise((resolve) => {
const response = streamSSE(c, async (stream) => {
// do all the streaming etc.
resolve(response);
})
});
return response;
const response = await new Promise((resolve) => {
const response = streamSSE(c, async (stream) => {
// do all the streaming etc.
resolve(response);
})
});
return response;
But then it doesn't stream at all as I was afraid. My guess is that since Hono doesn't get the response object back from the handler, it won't process the stream.
13 replies
HHono
Created by reko on 5/14/2025 in #help
How to wait for streamSse to finish?
Let me try that, my only worry is that will it somehow mess up the streaming if I don't return the Response object immediately.
13 replies