Keep Stream.range advancing with a zero-sized chunk - #6900
Conversation
🦋 Changeset detectedLatest commit: 68fe429 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Reproduction test for
Stream.rangewith zero chunk size: Added a test atpackages/effect/test/Stream.test.ts:407that callsStream.range(1, 3, 0)and expects[1, 2, 3]. The test correctly usestake(4)to bound collection so the buggy infinite-emit path doesn't hang.
Tracing Stream.range (Stream.ts:1567) confirms the bug: when chunkSize = 0, Arr.range(start, start + 0 - 1) ⇒ Arr.range(start, start - 1) returns [start], and start += 0 never advances the cursor, so every pull emits the same value. The assertion [1, 2, 3] correctly represents the expected contract and will fail against the buggy output [1, 1, 1, 1].
The test follows all conventions — it.effect, Effect.gen, assert from @effect/vitest, proper placement adjacent to the existing range test.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
Stream.range with chunkSize zero emits the lower bound forever instead of the finite inclusive range.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
Zero-sized range chunks never advance
Module:
StreamAudit ID:
core-s-z-testing-stream-range-zero-chunkSeverity / confidence: high / high
What happens
Stream.range with chunkSize zero emits the lower bound forever instead of the finite inclusive range.
Why it happens
With chunkSize === 0, the remaining > chunkSize branch emits [start] and advances start by zero, so every pull repeats the lower bound.
Expected behavior
range(min, max, chunkSize) emits the finite inclusive integer range when min <= max; chunkSize controls batching, not values, and no positive-only precondition is documented.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/Stream.ts:1567-1585View problematic code at
packages/effect/src/Stream.ts:1567-1585View exact lines on GitHub
Reproduction
Observed failure: [1, 1, 1, 1] instead of [1, 2, 3]
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
Audit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715fcore-s-z-testing-stream-range-zero-chunkCloses EFF-349