Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Editing blocked because of cursor position error #173

Closed
1 of 2 tasks
AntoLC opened this issue Nov 27, 2024 · 2 comments
Closed
1 of 2 tasks

Editing blocked because of cursor position error #173

AntoLC opened this issue Nov 27, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@AntoLC
Copy link

AntoLC commented Nov 27, 2024

Checklist

Describe the bug

When we are multiples users editing in the same time, a cursor error appears sometimes (hard to reproduce).
When the error appear it becomes impossible for everybody to edit.

Errors log

Unhandled Runtime Error

TypeError: Range.setStart: Argument 1 is not an object.
Call Stack
_isDomSelectionInView
javascript\node_modules\y-prosemirror\src\plugins\sync-plugin.js (334:1)
_isLocalCursorInView
javascript\node_modules\y-prosemirror\src\plugins\sync-plugin.js (325:1)
_typeChanged/<
javascript\node_modules\y-prosemirror\src\plugins\sync-plugin.js (560:1)
createMutex/<
javascript\node_modules\lib0\mutex.js (35:1)
_typeChanged
javascript\node_modules\y-prosemirror\src\plugins\sync-plugin.js (526:1)
callAll
javascript\node_modules\lib0\function.js (19:1)
callEventHandlerListeners
javascript\node_modules\yjs\dist\yjs.mjs (1984:3)
cleanupTransactions/</<
javascript\node_modules\yjs\dist\yjs.mjs (3278:1)
cleanupTransactions/<
javascript\node_modules\yjs\dist\yjs.mjs (3259:1)
callAll
javascript\node_modules\lib0\function.js (19:1)
cleanupTransactions
javascript\node_modules\yjs\dist\yjs.mjs (3283:14)
transact
javascript\node_modules\yjs\dist\yjs.mjs (3409:1)
readUpdateV2
javascript\node_modules\yjs\dist\yjs.mjs (1649:1)
applyUpdateV2
javascript\node_modules\yjs\dist\yjs.mjs (1744:1)
applyUpdate
javascript\node_modules\yjs\dist\yjs.mjs (1758:1)

Potential solution
Here:

this._domSelectionInView = this._isDomSelectionInView()

+      try {
+          this._domSelectionInView = this._isDomSelectionInView()
+      }
+      catch (e) {
+         this._domSelectionInView = false
+      }

-      this._domSelectionInView = this._isDomSelectionInView() 

... 

It will not solve the bug but it will not block the editing anymore.


Thank you !

@YousefED
Copy link

YousefED commented Dec 3, 2024

Nice find! Instead of a try / catch we probably want to handle the case a bit more cleanly (for example, handling "None" selection?). I hope @dmonad can weigh in, see numerique-gouv/impress#440 for more details

@dmonad
Copy link
Member

dmonad commented Dec 4, 2024

Thanks for the stack trace!

I don't like catching errors that I didn't expect. So I tried fixing the underlying cause. I could imagine that if there is no dom selection, there would be an exception because selection.anchorNode is null in sync-plugin.js#334. Now the code guards against this behavior.

I just published a new release that, hopefully, fixes this issue. Please reopen this ticket if you can produce a new stack trace.

@dmonad dmonad closed this as completed Dec 4, 2024
dmonad added a commit that referenced this issue Dec 4, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants