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

[store-zustand] race conditions with states #12

Open
Ainias opened this issue Dec 23, 2024 · 0 comments
Open

[store-zustand] race conditions with states #12

Ainias opened this issue Dec 23, 2024 · 0 comments

Comments

@Ainias
Copy link

Ainias commented Dec 23, 2024

If you send multiple updates from different content scripts simultaniously, only the last one will be saved.
In my example I have a record inside the store. My state is

{
characters: Record<string, string[]>
} 

And I open multiple iFrames, each one collecting data for a single character.
Often times the data is collected at the same time, so two or more content scripts are sending the full state to the backend-script. But they do not have the state (character infos) from the other iFrames and therefore only the last state is saved correctly.

Maybe a state-update method (like shallow-merge/deep-merge) could be added to the initPegasusZustandStoreBackend-State. And deleting of states must be set to null or undefined directly?

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

No branches or pull requests

1 participant