Skip to content

Conversation

@raiden-staging
Copy link

@raiden-staging raiden-staging commented Aug 5, 2025

  • Websocket event system/pong works with client live view heartbeat now ✅

Next Steps :

  • onkernel/neko
    • Merge PR (Keepalive fix cleanup [neko])
    • Release tag v3.0.6-v1.0.1
  • onkernel/kernel-images
    • Merge PR (Keepalive fix cleanup [kernel-images]). Notes :
      • Dockerfile already set to ghcr.io/onkernel/neko/base:3.0.6-v1.0.1
      • after onkernel/neko:v3.0.6-v1.0.1 tag release and build completion, would work directly

[ @Sayan- @rgarcia ]

@mesa-dot-dev
Copy link

mesa-dot-dev bot commented Aug 5, 2025

Mesa Description

TL;DR

Refactored the WebSocket keepalive mechanism to use a dedicated SYSTEM_PONG event with a timestamp in response to client heartbeats, improving reliability and clarity.

Why we made these changes

To ensure the client live view heartbeat functions correctly and to standardize the WebSocket keepalive process using a more robust SYSTEM_PONG acknowledgment, enhancing server-client communication stability.

What changed?

  • server/internal/http/legacy/event/events.go: Added SYSTEM_HEARTBEAT and SYSTEM_PONG constants.
  • server/internal/http/legacy/message/messages.go: Introduced SystemPong struct with Event and Timestamp fields.
  • server/internal/http/legacy/wstobackend.go: Modified CLIENT_HEARTBEAT handler to respond with SYSTEM_PONG including a timestamp, utilizing strconv and time packages.
  • server/internal/websocket/handler/handler.go: Streamlined client heartbeat handling; CLIENT_HEARTBEAT now directly calls h.systemPong(session); h.systemPong(session) is now the default action for unhandled events.
  • server/internal/websocket/handler/system.go: Added a new systemPong function to MessageHandlerCtx to send the SYSTEM_PONG event with the current timestamp.
  • server/internal/websocket/manager.go: Enabled logging for SYSTEM_HEARTBEAT and CLIENT_HEARTBEAT events by removing them from nologEvents.
  • server/pkg/types/event/events.go: Added SYSTEM_PONG to system event types.
  • server/pkg/types/message/messages.go: Introduced SystemPong struct for server responses to client heartbeats.

Copy link

@mesa-dot-dev mesa-dot-dev bot left a comment

Choose a reason for hiding this comment

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

What Changed

This PR refactors the websocket keepalive mechanism to use a more standard ping/pong pattern. The server now responds to a CLIENT_HEARTBEAT event with a new SYSTEM_PONG event, which includes a server-side timestamp.

This change aligns the keepalive functionality with the client's live view heartbeat. The updates have been applied to both the current and legacy websocket handlers, ensuring consistent behavior. Logging for heartbeat-related events has also been enabled to improve observability.

Risks / Concerns

No risks identified. This is an excellent cleanup that simplifies and clarifies the websocket keepalive logic, making it more robust and easier to understand. The changes are well-contained and thoughtfully implemented.

8 files reviewed | 0 comments | Review on Mesa | Edit Reviewer Settings

@rgarcia rgarcia merged commit 826e0c9 into kernel:master Aug 5, 2025
3 checks passed
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.

2 participants