Skip to content

chore(livestream): Don't send messages to unsubscibed clients in the livestream service#45977

Closed
jordanm-posthog wants to merge 1 commit intomasterfrom
jordanm-posthog/skipSendingToUnsub
Closed

chore(livestream): Don't send messages to unsubscibed clients in the livestream service#45977
jordanm-posthog wants to merge 1 commit intomasterfrom
jordanm-posthog/skipSendingToUnsub

Conversation

@jordanm-posthog
Copy link
Copy Markdown
Contributor

Problem

The Livestream service currently sends messages regardless if the user is actually subscribed to the SSE stream to receive it.

Changes

  • Skip geo-lookup processing when there are no active subscribers
  • Skip sending messages to the outgoing channel when there are no active subscribers
  • Add Counter type to track active subscriptions

How did you test this code?

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Publish to changelog?

No

@jordanm-posthog jordanm-posthog requested a review from orian January 27, 2026 03:58
// considered "inactive" when all consumers have unregistered.
type Counter struct {
keys map[string]int
mu sync.RWMutex
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure if there is a "better" way to do thread safe look ups. I don't love the idea of using locks here but it seems relatively safe (for now)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 3, 2026

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

@github-actions github-actions Bot added the stale label Feb 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@github-actions github-actions Bot closed this Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant