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

[BUG]: Liveblocks is temporarily duplicating frequently changed array values #1051

Open
noahbaron91 opened this issue Aug 4, 2023 · 3 comments · May be fixed by #1002
Open

[BUG]: Liveblocks is temporarily duplicating frequently changed array values #1051

noahbaron91 opened this issue Aug 4, 2023 · 3 comments · May be fixed by #1002
Assignees
Labels
bug Something isn't working triage needed The issue needs to be reviewed by the team

Comments

@noahbaron91
Copy link

noahbaron91 commented Aug 4, 2023

Describe the bug

Frequently changing array values are being temporarily duplicated by liveblocks when using the Zustand connector.

I prepared a simple example that displays this issue, similar to the project I'm working on: https://github.com/noahbaron91/liveblocks-array-bug / https://stackblitz.com/github/noahbaron91/liveblocks-array-bug

In this example, a layer is moving in and out of another layer at a quick rate. Liveblocks will randomly duplicate the stored ids when updated at a fast rate (approx 50ms per action).

I have noticed that it quickly recovers, but this short duplication is causing issues for me.

Steps to reproduce the behavior:

  1. Go to https://stackblitz.com/github/noahbaron91/liveblocks-array-bug or clone https://github.com/noahbaron91/liveblocks-array-bug
  2. Create a .env file with a VITE_LIVEBLOCKS_PUBLIC_API_KEY value or fill in the public API key directly
  3. Run yarn install and yarn run dev
  4. Run the app. The app throws an error when there are duplicate child ids.
  5. You can disable liveblocks from storing the layers property to confirm that the app is working properly

Expected behavior

Liveblocks should not duplicate array values and should instead stay consistent with the Zustand storage

Illustrations

liveblocks-bug.mp4

Environment (please complete the following information):

  • Liveblocks packages and packages version:
    "@liveblocks/client": "^1.2.1",
    "@liveblocks/zustand": "^1.2.1",
  • Browser's version:
    Chrome 115 on macOS (Ventura)
@noahbaron91 noahbaron91 added bug Something isn't working triage needed The issue needs to be reviewed by the team labels Aug 4, 2023
@noahbaron91 noahbaron91 changed the title [BUG]: Liveblocks is duplicating frequently changed array values [BUG]: Liveblocks is temporarily duplicating frequently changed array values Aug 5, 2023
@nvie nvie self-assigned this Aug 17, 2023
@nvie nvie linked a pull request Aug 7, 2023 that will close this issue
@nvie nvie linked a pull request Aug 17, 2023 that will close this issue
@nvie
Copy link
Collaborator

nvie commented Aug 17, 2023

Hi @noahbaron91 - thank you for reporting this bug. Please excuse our delay in response here – part of our support team was out for holidays.

This looks like an instance of a bug we already have on our radar (see #628 and #731). We have a potential fix for this, currently in draft in #1002, which still needs to be unit tested properly, and verified for production-readiness. We'll keep you posted on when we have an official release for this bug fix.

If you're willing and able to help us verify that this fixes your issue in the mean time, you could:

npm install @liveblocks/client@1.2.2-test5 @liveblocks/zustand@1.2.2-test5

Does that fix your issue as expected? Thanks in advance! 🙏

@noahbaron91
Copy link
Author

noahbaron91 commented Aug 17, 2023

No problem @nvie,
Unfortunately, using version 1.2.2-test5 does not resolve the issue for me. I'm still experiencing the same duplication of list elements when using that version

@nvie
Copy link
Collaborator

nvie commented Aug 17, 2023

That's unfortunate, we'll have to keep digging a bit more then. Thanks for trying it out and letting us know, @noahbaron91.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage needed The issue needs to be reviewed by the team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants