Skip to content

Bound pending SSE writes under stalled consumers - #23

Merged
smiggleworth merged 3 commits into
mainfrom
issue/16-bounded-sse-writes
Aug 15, 2026
Merged

Bound pending SSE writes under stalled consumers#23
smiggleworth merged 3 commits into
mainfrom
issue/16-bounded-sse-writes

Conversation

@smiggleworth

@smiggleworth smiggleworth commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • cap unresolved SSE writes at highWaterMark before retaining payload closures
  • defer serialization and encoding until the accepted write reaches stream capacity
  • reject overflow immediately with stable QuotaExceededError
  • release admission slots on every settlement path and skip heartbeats while full
  • document the bounded producer contract and retry/await obligation

Linked issue

Closes #16

TDD

  • Red c79c994: 100 unawaited calls formatted all 100 distinct 100 KB payloads synchronously against highWaterMark: 2.
  • Green 09c07ed: only two calls are admitted/formatted, 98 settle immediately as QuotaExceededError, and draining admits queued work in order.

Guardrails

  • deterministic many-unawaited/no-reader admission and serialization counts
  • overflow error identity and no retained formatting
  • drain/recovery ordering
  • deferred serialization failure releases capacity
  • stalled heartbeat coalescing
  • existing framing, abort, closed-stream, and idempotent-close coverage

Acceptance audit

Verification

  • npm run check
  • npm audit --omit=dev

@smiggleworth
smiggleworth marked this pull request as ready for review August 15, 2026 20:22
Copilot AI lite review requested due to automatic review settings August 15, 2026 20:22

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@smiggleworth
smiggleworth merged commit 4fbf745 into main Aug 15, 2026
3 checks passed
@smiggleworth
smiggleworth deleted the issue/16-bounded-sse-writes branch August 15, 2026 20:22
@smiggleworth

Copy link
Copy Markdown
Contributor Author

Release closure verified:

  • squash merge 4fbf7453fae679c4428ae56bdcf7b4b1ed8559be
  • publish workflow run 31906519837 passed all three CI lanes and the publish job at that exact SHA
  • annotated tag v0.0.17 peels to the merge SHA
  • npm serves @askrjs/server@0.0.17 with integrity sha512-X5zGyMr2n+EWqZktK7/pyBHW3rhU1bxj1jvfXH4HztEJOOcWyEY4ZutL/rBroNeh9lk+ABvR7MWZge2f+VvF5w==
  • a clean registry consumer with highWaterMark: 1 admitted/formatted one of ten 100 KB events and immediately rejected nine as QuotaExceededError, with zero eager serialization
  • clean consumer runtime audit reports zero vulnerabilities

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.

SSE send()/comment() grow memory unboundedly with an unawaited producer against a stalled consumer

2 participants