Skip to content
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

Bun stream "direct" #16054

Open
moshOntong-IT opened this issue Dec 30, 2024 · 0 comments
Open

Bun stream "direct" #16054

moshOntong-IT opened this issue Dec 30, 2024 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@moshOntong-IT
Copy link

What version of Bun is running?

1.1.42

What platform is your computer?

Windows

What steps can reproduce the bug?

import { sleep } from "bun";

const stream = new ReadableStream({
  // @ts-ignore
  type: "direct",
  // @ts-ignore
  async pull(controller) {
    // @ts-ignore
    controller.write("hello");

    await sleep(1000);
    console.log("start");

    await sleep(1000);
    // @ts-ignore
    controller.write("world");

    // set time oujt below

    controller.close();
  },
});
// .pipeTo(
//   new WritableStream({
//     write(chunk) {
//       console.log(chunk);
//     },
//   })
// );
// @ts-ignore
for await (const chunk of stream) {
  console.log(chunk);
  // => "hello"
  // => "world"
}

Run the code:

What is the expected behavior?

  1. The expected is that when I trigger the write, for those who listen to this stream, he will receive the event. (It means each write trigger it will be send to the user who listen to this stream)
  2. The expected of value type is string because "hello" and "world" is a string type hence the expected data to be received is literally "hello" and world"

What do you see instead?

  1. It will wait to close the readable stream before the user received the event.
  2. Received an Uint8Array data type.

Additional information

No response

@moshOntong-IT moshOntong-IT added bug Something isn't working needs triage labels Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

1 participant