Skip to content

Commit

Permalink
Fix bug where space.enter() sometimes wouldn’t return
Browse files Browse the repository at this point in the history
Calling presence.enter() does not necessarily result in the presence
object emitting an ENTER event. This could happen, for example, if the
channel does not become attached quickly enough, or if a transport
upgrade is happening at roughly the same time as the presence enter call
(note that the latter possibility means that we wouldn’t gain much by
trying to work around the former by making sure the channel becomes
attached before performing the presence enter). In both these cases, the
only visible side effect of the presence enter call will be a PRESENT
event emitted as a result of a presence SYNC.

So, we update space.enter such that it also will return if it receives a
PRESENT event for the current member.

Resolves COL-335.
  • Loading branch information
lawrence-forooghian committed Oct 19, 2023
1 parent 1a43536 commit 3335598
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class Space extends EventEmitter<SpaceEventMap> {
resolve(members);
};

presence.subscribe('enter', presenceListener);
presence.subscribe(['enter', 'present'], presenceListener);

const update = new SpaceUpdate({ self: null, extras: null });
this.presenceEnter(update.updateProfileData(profileData));
Expand Down

0 comments on commit 3335598

Please sign in to comment.