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: Avoid race condition that may initialize a document twice on the clients #5470

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

juliushaertl
Copy link
Member

@juliushaertl juliushaertl commented Mar 13, 2024

This fix may help with duplicate content of documents.

While staring at code and reading yjs/yjs-demos#16 I noticed we may have a race condition where two browsers would attempt to create a new document, while that is catched the session receiving the unique constraint exception would still continue with the freshSession value set to true and handing over the file content and using that to initialize the document again locally.

… clients

Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliushaertl juliushaertl added bug Something isn't working 3. to review labels Mar 13, 2024
@juliushaertl juliushaertl mentioned this pull request Mar 13, 2024
Copy link
Member

@mejo- mejo- left a comment

Choose a reason for hiding this comment

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

Looks sensible to me 👌

@juliushaertl juliushaertl merged commit e2ad77e into main Mar 13, 2024
61 checks passed
@juliushaertl juliushaertl deleted the fix/duplicate-document-init-race branch March 13, 2024 16:22
@juliushaertl
Copy link
Member Author

/backport to stable28

@juliushaertl
Copy link
Member Author

/backport to stable27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants