Skip to content
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

Audience Service is Not Returning Accurate User Data #23456

Open
neerajcharokar opened this issue Jan 6, 2025 · 1 comment
Open

Audience Service is Not Returning Accurate User Data #23456

neerajcharokar opened this issue Jan 6, 2025 · 1 comment
Labels
bug Something isn't working community-contribution

Comments

@neerajcharokar
Copy link
Contributor

Describe the bug

While using the Audience Service of RouterlicioutClient, we observed that a user remains marked as connected even after being disconnected. For example, when UserA connects to the container, the Audience Service correctly shows UserA as connected along with their details. However, when UserA disconnects, the Audience Service continues to display them as connected to the container in the service response.

Image

To Reproduce

Steps to reproduce the behavior:

  1. call createContainer()
  2. Use the service instance returned by createContainer and call audience.getMembers()
  3. log the data got from getMembers()

Expected behavior

The Audience service should display the exact number of clients. As in the above example, once UserA disconnects, it should show zero clients or an empty map.

Logs

@znewton
Copy link
Contributor

znewton commented Jan 9, 2025

Explanation

@neerajcharokar this is expected behavior. To clarify for anyone who comes across this, I confirmed via DMs that the reproduction steps are actually as follows

// This is tehcnically pseudocode, don't expect this to compile as-is
const { container, services }  = azureClient.createContainer();
console.log(services.audience.getMembers()); // "[client1]"
// The following "disconnect" call was left out in the original repro steps,
// and this is crucial to understanding why the Audience is not updating
container.disconnect();
console.log(services.audience.getMembers()); // "[client1]"
await delay(10_000);
console.log(services.audience.getMembers()); // "[client1]"

The reason the Audience stops being updated is that the container instance is disconnected after calling disconnect(). That means it will not receive any new join or leave Ops or Signals.

Opinion

Yes, we could go through the effort of adding Audience service functionality to remove the current user from the audience specifically on disconnect(); however, this would be supporting a very niche, likely unintended use-case. More importantly, even if we removed the current user from their (now offline) Audience service instance immediately on disconnect(), the rest of the Audience information would also have to be considered stale.

Perhaps, instead, to make the experience here more clear, we should instead throw some type of error on audience.getMembers() when the container is disconnected() to make it more clear that the real-time Audience info is not actually available. Alternatively, returning an empty list would probably send the same message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community-contribution
Projects
None yet
Development

No branches or pull requests

2 participants