This PR fixes issue #9810 by ensuring buffer(n) does not run more than n elements ahead of downstream:

Changes

  • For buffer(1): Use synchronous handoff with Promise to ensure exactly 1 element is buffered. The producer waits for the consumer to acknowledge receipt before producing the next element.

  • For buffer(n) where n > 1: Use queue of size n-1 (accounting for in-flight element)

  • For buffer(0) or negative: Keep original behavior

Technical Details

The fix uses and to maintain laziness of the capacity parameter, which is required for backward compatibility.

Testing

All 1136 tests pass, including:

  • StreamLazinessSpec (185 tests)
  • All existing buffer-related tests

Closes #9810 /claim #9810

Claim

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

Contributors

TI

tianlin-magi

@tele-he-gmail-com

100%

Sponsors

ZI

ZIO

@ZIO

$250