Summary

Fix ZStream.buffer(1) so it only buffers exactly 1 element instead of 2.

Fixes #9810

Problem

ZStream.buffer(1) was incorrectly buffering 2 elements instead of 1, due to the asynchronous nature of the underlying queue implementation. This occurred because the queue allowed concurrent offer and take operations, leading to a race condition.

Solution

  • For buffer(1): use a synchronous handoff to ensure only one element is buffered at any time
  • For buffer(n) where n > 1: use queue capacity of n - 1 to account for the in-flight element

Test plan

  • Added regression tests for buffer(1) behavior
  • Added regression tests for buffer(2) behavior

/claim #9810

Claim

Total prize pool $250
Total paid $0
Status Pending
Submitted February 24, 2026
Last updated February 24, 2026

Contributors

ER

Erichhhhhcat

@Erichhhhhcat

100%

Sponsors

ZI

ZIO

@ZIO

$250