Skip to content

Conversation

@DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Jan 23, 2026

Relates to #19715

This is similar to #19711

This endpoint works by doing the following:

  • Subscribing to the database's with pubsub
  • Accepts a WebSocket upgrade
  • Starts a httpapi.Heartbeat
  • Creates a json encoder
  • Infinitely loops waiting for notification until request context cancelled

The critical issue here is that httpapi.Heartbeat silently fails when the client has disconnected. This means we never cancel the request context, leaving the WebSocket alive until we receive a notification from the database and fail to write that down the pipe.

By replacing usage of httpapi.Heartbeat with httpapi.HeartbeatClose, we cancel the context when the heartbeat fails to write due to the client disconnecting. This allows us to cleanup without waiting for a notification to come through the pubsub channel.

This is similar to #19711

The way this endpoint works is that it subscribes to the database for
notifications. When a notification is received, it pipes that
notification down the WebSocket. If
@DanielleMaywood DanielleMaywood marked this pull request as ready for review January 23, 2026 15:36
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

Stamp 👍

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

LGTM!

@DanielleMaywood DanielleMaywood merged commit 409360c into main Jan 26, 2026
30 of 32 checks passed
@DanielleMaywood DanielleMaywood deleted the danielle/fix/websocket-leak branch January 26, 2026 09:24
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2026
@johnstcn johnstcn added cherry-pick/v2.28 Needs to be cherry-picked to the 2.28 release branch cherry-pick/v2.29 Needs to be cherry-picked to the 2.29 release branch cherry-pick/v2.27 Items to be pulled in for the v2.27 release. labels Jan 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cherry-pick/v2.27 Items to be pulled in for the v2.27 release. cherry-pick/v2.28 Needs to be cherry-picked to the 2.28 release branch cherry-pick/v2.29 Needs to be cherry-picked to the 2.29 release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants