Normalize unbounded PubSub replay capacities - #7244
Conversation
🦋 Changeset detectedLatest commit: e66525a 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 |
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes how unbounded PubSub replay capacity is interpreted so it behaves consistently with bounded PubSubs and does not accidentally become “infinite history” due to fractional or non-positive values.
Changes:
- Normalize unbounded replay configuration: only
replay > 0enables replay, and fractional values are rounded up viaMath.ceil. - Add tests covering fractional replay rounding and disabling replay for non-positive values.
- Add a changeset documenting the patch-level behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/effect/src/PubSub.ts | Normalizes unbounded atomic replay buffer creation to use positive integer capacities (ceil + positive check). |
| packages/effect/test/PubSub.test.ts | Adds regression tests for fractional replay rounding and non-positive replay disabling on unbounded PubSubs. |
| .changeset/normalize-unbounded-pubsub-replay.md | Documents the patch release note for the replay normalization behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
What
Unbounded PubSubs passed replay values directly to
ReplayBuffer. Fractional capacities could never equal the buffer's integer size, so eviction never ran and late subscribers received the full publication history. Negative replay values also enabled an effectively unbounded replay buffer.Fix
Normalize unbounded replay settings the same way as bounded PubSubs: only positive values enable replay, and fractional capacities are rounded up.
Tests
pnpm lint-fixpnpm test --run packages/effect/test/PubSub.test.tspnpm check