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.$(...).lines() AsyncIterator does not stream #16011

Open
ctjlewis opened this issue Dec 27, 2024 · 0 comments
Open

Bun.$(...).lines() AsyncIterator does not stream #16011

ctjlewis opened this issue Dec 27, 2024 · 0 comments
Labels
bug Something isn't working needs triage

Comments

@ctjlewis
Copy link

ctjlewis commented Dec 27, 2024

What version of Bun is running?

1.1.41-canary.29+b8f28ed8a

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

Repro test: https://github.com/ctjlewis/bun-stream-lines (index.test.ts).

What is the expected behavior?

test("line iterator should iterate as lines are written to stream", async () => {
  const bunLines = 
    Bun
      .$`sleep 1; echo "1"; sleep 1; echo "2"; sleep 1; echo "3";`
      .lines()

  let lastTime = performance.now()
  for await (const line of bunLines) {
    const currentTime = performance.now()
    const delta = currentTime - lastTime

    console.log(`Line: ${line} took ${delta}ms`)
    lastTime = performance.now()
    
    expect(delta).toBeGreaterThan(1_000)
  }
})

The AsyncIterator returned by Bun.$(...).lines() should iterate as lines are written rather than being buffered. Had to revert to old Node APIs with callbacks, thought it was my bug.

@ctjlewis ctjlewis added bug Something isn't working needs triage labels Dec 27, 2024
@ctjlewis ctjlewis changed the title Bun.$(...).lines() AsyncIterator does not stream Bun.$(...).lines() AsyncIterator does not stream Dec 27, 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