Giter VIP home page Giter VIP logo

Comments (4)

pg-wtatum avatar pg-wtatum commented on August 26, 2024

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.

pg-wtatum avatar pg-wtatum commented on August 26, 2024

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.

directormac avatar directormac commented on August 26, 2024

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.

pg-wtatum avatar pg-wtatum commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.