Skip to content

Normalize unbounded PubSub replay capacities - #7244

Merged
tim-smart merged 2 commits into
Effect-TS:mainfrom
AnnaSuSu:agent/fix-unbounded-pubsub-replay-capacity
Aug 14, 2026
Merged

Normalize unbounded PubSub replay capacities#7244
tim-smart merged 2 commits into
Effect-TS:mainfrom
AnnaSuSu:agent/fix-unbounded-pubsub-replay-capacity

Conversation

@AnnaSuSu

Copy link
Copy Markdown
Contributor

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

  • Added coverage for fractional replay capacity rounding.
  • Added coverage for disabling non-positive replay values.
  • pnpm lint-fix
  • pnpm test --run packages/effect/test/PubSub.test.ts
  • pnpm check

@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e66525a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
effect Patch
@effect/ai-anthropic Patch
@effect/ai-openai Patch
@effect/ai-openai-compat Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/openapi-generator Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node Patch
@effect/platform-node-shared Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/vitest Patch

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

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 6.92 KB 6.92 KB 0.00 KB (0.00%)
batching.ts 9.73 KB 9.73 KB 0.00 KB (0.00%)
brand.ts 6.50 KB 6.50 KB 0.00 KB (0.00%)
cache.ts 10.63 KB 10.63 KB 0.00 KB (0.00%)
config.ts 21.06 KB 21.06 KB 0.00 KB (0.00%)
differ.ts 20.00 KB 20.00 KB 0.00 KB (0.00%)
http-client.ts 21.55 KB 21.55 KB 0.00 KB (0.00%)
logger.ts 10.89 KB 10.89 KB 0.00 KB (0.00%)
metric.ts 8.86 KB 8.86 KB 0.00 KB (0.00%)
optic.ts 6.67 KB 6.67 KB 0.00 KB (0.00%)
pubsub.ts 14.91 KB 14.91 KB 0.00 KB (0.00%)
queue.ts 11.58 KB 11.58 KB 0.00 KB (0.00%)
schedule.ts 10.73 KB 10.73 KB 0.00 KB (0.00%)
schema-class.ts 19.61 KB 19.61 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.57 KB 29.57 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 25.80 KB 25.80 KB 0.00 KB (0.00%)
schema-string-transformation.ts 13.50 KB 13.50 KB 0.00 KB (0.00%)
schema-string.ts 10.99 KB 10.99 KB 0.00 KB (0.00%)
schema-template-literal.ts 15.30 KB 15.30 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 21.74 KB 21.74 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 24.20 KB 24.20 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 18.96 KB 18.96 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 18.78 KB 18.78 KB 0.00 KB (0.00%)
schema-toFormatter.ts 18.65 KB 18.65 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 22.81 KB 22.81 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 19.30 KB 19.30 KB 0.00 KB (0.00%)
schema.ts 18.86 KB 18.86 KB 0.00 KB (0.00%)
stm.ts 12.67 KB 12.67 KB 0.00 KB (0.00%)
stream.ts 9.67 KB 9.67 KB 0.00 KB (0.00%)

@AnnaSuSu
AnnaSuSu marked this pull request as ready for review August 14, 2026 01:50
Copilot AI lite review requested due to automatic review settings August 14, 2026 01:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 > 0 enables replay, and fractional values are rounded up via Math.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.

Comment thread packages/effect/src/PubSub.ts Outdated
@tim-smart
tim-smart merged commit b660bf0 into Effect-TS:main Aug 14, 2026
13 of 15 checks passed
@AnnaSuSu
AnnaSuSu deleted the agent/fix-unbounded-pubsub-replay-capacity branch August 14, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants