Skip to content

Calling track fires both the join and leave events #1167

Open
@netgfx

Description

@netgfx

Bug report

  • [x ] I confirm this is a bug with Supabase, not with my own application.
  • [x ] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When calling presence.track() the join and leave events are firing as well

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. setup listeners:
const presence = presenceChannel
           .on('presence', { event: 'sync' }, () => {
              const state = presenceChannel.presenceState<PresencePlayer>()
          })
          .on(
           'presence',
           { event: 'join' },
           ({ key, newPresences }) => {
                console.log('Player joined:', key, newPresences)
            })
          .on(
         'presence',
         { event: 'leave' },
          ({ key, leftPresences }) => {
                console.log('Player left:', key, leftPresences)
           } )
    }
     ```
   2. call track `presence.track(updatedPlayer)`
   3. The join and leave events fire

## Expected behavior

The join and leave events don't fire if there is no new user joining or leaving

## Screenshots

![image](https://github.com/user-attachments/assets/578a4243-8f61-4cde-89a8-ab5ce7f31b66)

## System information

- OS: Windows
- Browser: chrome
- Version of supabase-js: 2.45.4
- Version of Node.js: 20.17.0

## Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions