Skip to content

Conversation

@edgurgel
Copy link
Member

🔍 Description

Expose latency for heartbeats when we get a reply. Only available for status ok and error otherwise undefined. It's backwards compatible because the second argument is number | undefined so a callback with just one argument will stil work fine.

I've also changed so that it matches the heartbeatRef when the message arrives. This avoids any potential race condition where the message for a previous heartbeat arrives later but we had already given up on that previous heartbeat.

What changed?

An extra latency can be passed to the heartbeat callback when heartbeat gets a reply from the server. RealtimeClient keeps track of the last time the heartbeat was sent and provide the diff.

Why was this change needed?

A feature that can help people react to high latency users like people on slow mobile internet.

📸 Screenshots/Examples

🔄 Breaking changes

  • This PR contains no breaking changes

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format: <type>(<scope>): <description>
  • I have run npx nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

📝 Additional notes

@edgurgel edgurgel requested review from a team as code owners December 23, 2025 01:05
@github-actions github-actions bot added the realtime-js Related to the realtime-js library. label Dec 23, 2025
@edgurgel edgurgel added trigger: preview and removed realtime-js Related to the realtime-js library. labels Dec 23, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 23, 2025

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@1982

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@1982

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@1982

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@1982

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@1982

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@1982

commit: c6f31b2

@edgurgel
Copy link
Member Author

I've updated multiplayer.dev to use that instead of a custom room for the latency display:

supabase/multiplayer.dev#10

https://realtime-demo-ka5nlzyra-supabase.vercel.app/

@mandarini mandarini merged commit 497af72 into master Dec 23, 2025
26 checks passed
@mandarini mandarini deleted the feat/expose-heartbeat-latency branch December 23, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants