Skip to content

Add observability when an SSE subscriber callback throws in src/streams/sseEmitter.tsΒ #496

Description

@Jagadeeshftw

πŸ“Œ Description

In src/streams/sseEmitter.ts the subscriber fan-out wraps each callback in a try/catch and swallows the error so one bad listener doesn't break the others. While the isolation is correct, the catch is silent β€” there is no log or metric when a subscriber throws, so a persistently failing listener is invisible.

πŸ’‘ Why it matters: Silent error isolation hides bugs; a misbehaving SSE listener could be failing every event with zero signal to operators.

🧩 Requirements and context

  • Emit a structured log (with stream id + error) when a subscriber callback throws.
  • Add a prom-client counter (e.g. fluxora_sse_subscriber_errors_total) for thrown subscriber callbacks.
  • Keep the existing isolation behavior (other subscribers still receive the event).
  • Add a test that registers a throwing subscriber and asserts the log/metric fires while other subscribers still run.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

πŸ› οΈ Suggested execution

1. Fork the repo and create a branch

git checkout -b feat/sse-subscriber-error-observability

2. Implement changes

  • Write/modify the relevant source: src/streams/sseEmitter.ts, src/metrics/index.ts
  • Write comprehensive tests: tests/routes/streams-sse.test.ts
  • Add documentation: metric name in observability docs
  • Include TSDoc doc comments
  • Validate security assumptions: error logs carry no PII

3. Test and commit

  • Run tests:
npm test
  • Cover edge cases: one throwing + multiple healthy subscribers
  • Include test output and security notes in the PR description.

Example commit message

feat(sse): log and meter throwing SSE subscriber callbacks

βœ… Acceptance criteria

  • Throwing subscriber produces a structured log
  • Counter increments on subscriber error
  • Other subscribers still receive the event
  • Test verifies isolation + signal

πŸ”’ Security notes

Ensure SSE payloads (which may contain stream data) are not logged in full.

πŸ“‹ Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issueStellar WaveIssues in the Stellar wave programbackendBackend service workobservabilityLogging / metrics / tracingrefactorCode refactor / cleanup

Type

Fields

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions