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

Fix fast LiveList.insert + LiveList.set bug #1002

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

GuillaumeSalles
Copy link
Contributor

@GuillaumeSalles GuillaumeSalles commented Jul 14, 2023

Description

This PR ensures that insert acknowledge op is ignored if the item has been deleted by a local LiveList.set.

I took the opportunity to add comments and do some cleanups.

Before merging this, we need to make sure e2e tests are passing on public and private repositories. (We might need to fix our tests setup to work with ESM)

Review commit by commit recommended

How to test it

Upgrade our block based editor example to use 1.2.2-test3 and try to reproduce the behavior described in #731. This should also fix the "ghosting bug" mentioned by Fermat and Arcol.

Related issue(s)

@GuillaumeSalles GuillaumeSalles changed the base branch from main to y-sync-update July 14, 2023 17:38
@GuillaumeSalles GuillaumeSalles self-assigned this Jul 14, 2023
@@ -870,7 +892,7 @@ export class LiveList<TItem extends Lson> extends AbstractCrdt {
this._pool?.assertStorageIsWritable();
if (index < 0 || index > this._items.length) {
throw new Error(
`Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
`Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These error messages included some invisible characters between " and $

]);

expectStorage({
items: ["B"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the fix, items were equal to ["A","B"] here.

@GuillaumeSalles GuillaumeSalles changed the base branch from y-sync-update to main July 14, 2023 20:54
@GuillaumeSalles GuillaumeSalles changed the base branch from main to y-sync-update July 15, 2023 19:29
@GuillaumeSalles GuillaumeSalles changed the base branch from y-sync-update to main July 18, 2023 02:47
@jamesbvaughan
Copy link

Hi @GuillaumeSalles, we believe that we're hitting the error that this PR intends to fix. Do you know when we should expect more update here?

We're happy to help test out the fix if you can publish an updated -test release of the NPM packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants