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

Missing presence value in presence-changed event for initial presence #729

Open
chacha912 opened this issue Jan 19, 2024 · 0 comments
Open

Comments

@chacha912
Copy link
Contributor

What happened:

When a user sets an initial presence while attaching a document, a presence-changed event is triggered with an undefined presence value. This is because when publishing the presence-changed event, the presence is retrieved using getPresence, which only returns presence for online clients.

What you expected to happen:

The value of the presence-changed event should include the initial presence value set by the user.

How to reproduce it (as minimally and precisely as possible):

Execute following code:

it.only('initial presence', async function ({ task }) {
  const c1 = new yorkie.Client(testRPCAddr);
  await c1.activate();
  const c1ID = c1.getID()!;

  const docKey = toDocKey(`${task.name}-${new Date().getTime()}`);
  const events1 = new EventCollector<DocEvent>();
  type PresenceType = { key: string };
  const doc1 = new yorkie.Document<{}, PresenceType>(docKey);
  const unsub1 = doc1.subscribe('presence', (event) => events1.add(event));

  await c1.attach(doc1, {
    initialPresence: { key: 'val1' },
  });

  await events1.waitAndVerifyNthEvent(1, {
    type: DocEventType.PresenceChanged,
    value: { clientID: c1ID, presence: { key: 'val1' } },  // presence value is missing 
  });

  unsub1();
});

Anything else we need to know?:

Related: yorkie-team/yorkie#671

Environment:

  • Operating system:
  • Browser and version:
  • Yorkie version (use yorkie version):
  • Yorkie JS SDK version:
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

No branches or pull requests

1 participant