Skip to content

Initial document creation #471

@YousefED

Description

@YousefED

(I found this while investigating the freeze issue, but it might not be directly related to that)

Bug Report

When opening the document "Room record" (or creating a new document) and opening this in a new tab without making any changes, I get a yjs error Position x out of range.

After further investigation, I propose 2 fixes

Upgrade y-prosemirror

The "surface level" error seems to be fixed here: https://github.com/yjs/y-prosemirror/releases/tag/v1.2.13. I'll update y-prosemirror in BlockNote for the next release

Improve document creation

Document creation currently happens on the client side, if no existing document is returned from the server:

image

This brings us to the root cause. Multiple clients can "initiate" a yjs document if no document is retrieved from the server. This is pretty dangerous, as both users will start from a different yjs document. Even though it's initiated from the same content, the internal ids in the yjs document will differ. This will cause yjs to have trouble syncing content and / or cursor selections.

Recommended fix:

The ideal way to initialize the document is at the same time when the metadata (like the title / creation date / owner) is inserted in the database. Would this be possible?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions