-
-
Notifications
You must be signed in to change notification settings - Fork 670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(client/POC): RPC support for SSE #3957
base: main
Are you sure you want to change the base?
Conversation
Hi, @yusukebe This time, I would like to introduce Typed SSE that bypasses JSON as a feature of SSE RPC. Typed SSE is very useful, so I would like to introduce it. The problem is with the string. Most Hono Stream SSE users probably specify |
How about adding |
HI @nakasyou. |
Hi @sor4chi I don't want to introduce the polyfill of EventSource Parser. It increases package size and maintenance costs. Can you make it work with extending global objects like |
I can't think of a way to do this at the moment other than to cut it out as a sub-package and make it load only in environments where EventSource is available, such as a browser, and have the user explicitly switch between the two. |
This is an idea to reduce package size. What do you think of making $sse a function instead of a method. e.g: import { sse, hc } from 'hono/client'
const client = hc<typeof app>('/')
const source = sse(client.stream.get()) By doing that, the codebase will tree-shakeable. And we will be able to use POST requests to receive streaming. For example, most of LLM APIs such as OpenAI use POST method to stream content. It means that we can't use EventSource. Similarly, there are many users who want to use POST method to stream content using Hono RPC I guess. |
Thank you for the comments! The problem I'm having is not the bundle size but the package size. In other words, the amount of code included in the In this PR, you are using the import { sse } from '@hono/sse-client'
const client = hc<typeof app>('/')
const source = sse(client.stream.get()) |
Totally agree. I'll try it! |
@sor4chi Thank you for your understanding! |
resolve #3309
Todo
The author should do the following, if applicable
bun run format:fix && bun run lint:fix
to format the code