/claim #9810

Summary

Fix ZStream.buffer(n) so the requested capacity matches the actual number of elements that can be prefetched.

  • buffer(1) now uses a synchronous handoff path, so the producer cannot start a third element before the consumer asks for the second
  • buffer(n) for n > 1 uses an internal queue capacity of n - 1, which preserves exactly n total in-flight elements when combined with the consumer’s current element
  • adds regression tests covering the buffer(1) and buffer(2) distinction

Validation

Ran:

sbt -Dsbt.supershell=false "streamsTestsJVM/testOnly zio.stream.ZStreamSpec -- -t buffer"

Result: 22 tests passed, 0 failed.

Payout

If this bounty is rewarded, please attribute payout to @hriszc via the Algora account linked to this GitHub identity.

Notes

This keeps the change local to ZStream.buffer rather than redesigning queue internals. It also follows the discussion on the issue that buffer(1) is the special case requiring synchronous handoff semantics.

Claim

Total prize pool $250
Total paid $0
Status Pending
Submitted March 09, 2026
Last updated March 09, 2026

Contributors

HR

hriszc

@hriszc

100%

Sponsors

ZI

ZIO

@ZIO

$250