yjs/y-prosemirror

TypeError: nextytext.toDelta is not a function or its return value is not iterable

danny-hunt opened this issue · 2 comments

Crash caused by upgrading to 1.2.11

Checklist

Describe the bug
TypeError: nextytext.toDelta is not a function or its return value is not iterable shows on performing a specific action in the editor.
This caught error escalates to a crash on other actions (eg changing page)

I added some console logging in sync-plugin.js on my machine (logging out the type & nextytext):
image

And get these logs - showing an instance where nextytext does not have a toDelta function.
image

The command function here is the one that triggers the error for me. There must be more than one user collaborating at the same time for the bug to occur
image

I've patched the error locally via
image

To Reproduce
Apologies that I don't have a simple example case for this
Steps to reproduce the behavior:

  1. Two users in collaboration
  2. Open console
  3. Perform action that results in a nextytext that does not have a toDelta function (eg a YXmlElement)
  4. See error

Expected behavior
Would not expect a strict requirement for nextytext to have a toDelta function

Screenshots
Added above

Environment Information

  • node v22.4.0
  • chrome 127.0.6533.99 (Official Build) (arm64) (but it occurs across many setups
  • yjs 13.6.18
  • y-indexeddb 9.0.12
  • y-partykit 0.0.31
  • y-protocols 1.0.6
  • @syncedstore/yjs-reactive-bindings@0.6.0

Additional context

  • I'm a sponsor 💖
  • This issue is a blocker for my project.

I am also getting this issue when trying to copy an editor's contents to another using this:

xml2.insert(
    0,
    xml1
	.toArray()
	.filter((item) => !(item instanceof XmlHook))
	.map((item) => item.clone()),
);

Thank you for the bug report. The issue should be fixed in the latest release (1.2.12). Thanks to @manstie we have a bugfix. Please let me know if there is still an issue.