Comments (4)
To elaborate further on the object -> JSON question, if I implement my server side as a typed generator that produces something other than string the inferred client type in treaty is AsyncGenerator but in fact I just get the string [object Object]
instead
from elysia.
Sorry for the drip feed of info but the behavior is actually weirder than I first thought -- if I manually call JSON.stringify on the server, the values produced by
const res = await client.funky.get();
if (!res.error) {
for await (const d of res.data) {
console.log(d);
}
}
are objects rather than strings. This causes some significant typescript issues as I need to type the generator as string (but it actually returns objects)
edit to add I see that 1.1.3 was released today to address other issues related to the stream feature. I have updated and this appears to still be the case.
from elysia.
Currently implementing it using the Generator function as described in the docs, using for await
in both ends when data is string or a certain type, it's being inferred correctly but can't parse them well as sometimes it yields 2 or more at once. i think this needs to be moved at eden repo
from elysia.
Not sure it's strictly on the Eden side -- I've definitely seen cases where only one object is emitted and it still serializes onto the wire as [object Object], but if manually stringified with JSON.stringify it goes onto the wire as JSON (of course) and is parsed by Eden.
Given the content type is text/event-stream I would expect that the wire format is newline delimited and simultaneous emissions should not be an issue?
from elysia.
Related Issues (20)
- cors() doesn't work with new generator function HOT 10
- Setting headers inside generator functions doesn't work HOT 2
- TS linter complains about "body" has implicitly an "any" type for some routes in the same file
- v1.1.0 has a regression in the type for set.headers (no longer supports arrays) HOT 2
- Renaming handler parameters causes hang on start in v1.1.3 HOT 2
- Cannot destructure cookies in derive anymore HOT 1
- staticPlugin response NOT_FOUND HOT 2
- `bun build --minify` does not allow libraries to integrate with Elysia
- Async generator yielding an object results in `[object Object]` output HOT 4
- Async generator handler should follow `text/event-stream` protocol
- cannot destructure in derive HOT 2
- Elysia website crashes on Yandex Browser HOT 3
- Normalize option wrong documentation HOT 2
- onError nomally i can return custom response but now return value dosent work HOT 3
- Cannot match hostnames shorter than 4 chars HOT 3
- Query params following an array query are parsed as array items HOT 1
- Cookie: Right side of assignment cannot be destructured `aot: true` HOT 4
- Inconsistent behaviour of `aot` with `noop` handler / empty response HOT 2
- Type coercion not working when `aot` is off HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elysia.