honojs/hono

Allow stream helper arguments callback and onError to be synchronous functions

Closed this issue · 2 comments

What is the feature you are proposing?

Current:

Screenshot 2024-05-02 at 3 42 21
Screenshot 2024-05-02 at 3 42 29

How to resolve:

Simply change Promise<void> to Promise<void> | void

If it is good, I'll start developing it.

Hi @sor4chi

Simply change Promise<void> to Promise<void> | void

Though I might not understand what you meant completely, I think cb has to await, so it should be Promise<void>:

https://github.com/honojs/hono/blob/main/src/helper/streaming/stream.ts#L13

Oops, I forgot that stream.write is asynchronous to begin with. Sorry!