Skip to content

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

@chacha912

Description

@chacha912

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions