Skip to content

The generator's response is actually inconsistent #755

@HK-SHAO

Description

@HK-SHAO

What version of Elysia.JS is running?

1.1.4

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

server.ts:

import Elysia from "elysia";

export const app = new Elysia().post("/stream", async function* () {
  yield {hello: "world"};
  yield {hello: "world"};
  yield {hello: "world"};
});

app.listen(2345);

client.ts:

import { treaty } from "@elysiajs/eden";
import type { app } from ".";

const client = treaty<typeof app>("http://localhost:2345");

const { data, error } = await client.stream.post();
if (!data) throw error;

for await (let item of data) {
  console.log(item, typeof item);
}

What is the expected behavior?

% bun run client.ts
{
  hello: "world",
} object
{
  hello: "world",
} object
{
  hello: "world",
} object

What do you see instead?

% bun run client.ts
{"hello":"world"}{"hello":"world"} string
{
  hello: "world",
} object

Additional information

Sometimes numeric responses are merged together into a single number, and sometimes json obejct responses are merged into a single string. The same goes for non-asynchronous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions