Skip to content

fix(local): Use shared local master with bots#838

Merged
delucis merged 3 commits into
masterfrom
delucis/fix/800
Oct 26, 2020
Merged

fix(local): Use shared local master with bots#838
delucis merged 3 commits into
masterfrom
delucis/fix/800

Conversation

@delucis
Copy link
Copy Markdown
Member

@delucis delucis commented Oct 26, 2020

This returns a shared local master from the Local transport even when bots is passed in the options to Local. #553 changed this to avoid out-of-date bots persisting, but in the process broke scenarios where several clients should remain in sync on a single page (see #800). This implements a more careful check, returning a shared master as long as the bots options passed are equal to each other (via simple object equality).

The reliance on object identity could still represent a confusing gotcha, so in the future it might be better to offer a more explicit API for getting a new clean transport. Moving the global map of master instances inside the function scope of Local, could do this — calling Local would always return a new transport layer that could be shared around — but would potentially break current usage where repeatedly calling Local would still connect to the same master.

Fix #800

This returns a shared local master from the Local transport even when
`bots` is passed in the options to `Local`. #553 changed this to avoid
out-of-date bots persisting, but in the process broke scenarios where
several clients should remain in sync on a single page (see #800). This
implements a more careful check, returning a shared master as long as
the `bots` options passed are *equal* to each other (via simple object
equality).

The reliance on object identity could still represent a confusing
gotcha, so in the future it might be better to offer a more explicit
API for getting a new clean transport. Moving the global map of master
instances *inside* the function scope of `Local`, could do this —
calling `Local` would always return a new transport layer that could
be shared around — but would potentially break current usage where
repeatedly calling `Local` would still connect to the same master.

Fix #800
Totally subjective, but reads more clearly to me.
@delucis delucis merged commit ace1144 into master Oct 26, 2020
@delucis delucis deleted the delucis/fix/800 branch October 26, 2020 18:51
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

Successfully merging this pull request may close these issues.

Boards/bots not in sync after update to v0.38.0

1 participant