Skip to content

fix: Add heartbeat callback; Move to Sets vs Arrays #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 22, 2025

Conversation

filipecabaco
Copy link
Member

What kind of change does this PR introduce?

Add heartbeat callback; Move to Sets vs Arrays

@filipecabaco filipecabaco requested a review from Copilot April 7, 2025 22:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

@grdsdev grdsdev requested a review from Copilot April 22, 2025 09:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a heartbeat callback mechanism and refactors channel storage from arrays to Sets within the RealtimeClient, along with updating the tests accordingly.

  • Updates test assertions to use the new getChannels() helper instead of directly accessing the channels property.
  • Implements heartbeat callback functionality with additional tests for both successful and error heartbeats.
  • Refactors channel creation and removal logic to work with a Set instead of an array.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test/client.test.ts Updated test assertions to retrieve channels via getChannels() and added heartbeat tests.
test/channel.test.ts Updated channel removal assertions to use getChannels().
src/RealtimeClient.ts Changed channels from an array to a Set; added HeartbeatStatus type and heartbeat callback methods; updated channel creation and removal logic.
Comments suppressed due to low confidence (1)

src/RealtimeClient.ts:426

  • There is a spelling mistake in the error message ('hearbeat timeout'). It should be corrected to 'heartbeat timeout'.
this.conn?.close(WS_CLOSE_NORMAL, 'hearbeat timeout')

@filipecabaco filipecabaco merged commit 2ee9199 into master Apr 22, 2025
2 of 3 checks passed
@filipecabaco filipecabaco deleted the fix/heartbeat-callback branch April 22, 2025 11:05
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