In Eden some items will be objects, sometimes strings. This is because Elysia cannot distinguish what separate each yieled item. This is because the server does not separate yielded items with new lines
The type inference of Eden is wrong because when you yield a string it will be converted to an object. The server should call JSON.stringify on all yielded items if the handler is an async generator. (also this is what the text/event-stream spec says)
Elysia just calls .toString() on the yielded items, this will cause problems where when you yield objects you will get [object Object] #741
What version of Elysia.JS is running?
"elysia": "^1.1.3"
What platform is your computer?
Darwin 23.5.0 arm64 arm
What steps can reproduce the bug?
The output of this code will be:
There are several problems with this code:
[object Object]
#741https://github.com/elysiajs/elysia/blob/8173d905944b8b305f8989985abe7760af681de9/src/handler.ts#L156
What is the expected behavior?
Elysia should return a
text/event-stream
compatible output if the handler is an async generator:What do you see instead?
Elysia concatenates the outputs inline calling .toString() on each of them
Additional information
No response