How to solve this problem Method unimplemented

I wanted to develop a custom Socket.IO service provider, but when I tried it, a “Method Unimplemented” error was thrown on the console.

You are somehow passing probably an undefined Y.XmlElement to createNodeIfNotExists. Check you are passing the right doc to ySyncPlugin. By default, Yjs uses "prosemirror" as the key for a ProseMirror document. If you are creating a custom provider, you should use the same key or set the key yourself eg:

    const yXmlFragment = ydoc.getXmlFragment('pm-doc')
    const state = EditorState.create({
      plugins: exampleSetup({ schema, history: false }).concat([
        ySyncPlugin(yXmlFragment, {
          permanentUserData: permanentUserData,
          colors: [
            { light: '#ecd44433', dark: '#ecd444' },
            { light: '#ee635233', dark: '#ee6352' },
            { light: '#6eeb8333', dark: '#6eeb83' },
          'Mod-z': undo,
          'Mod-y': redo,
          'Mod-Shift-z': redo,

Thank you very much for your answer, my code has been implemented to synchronize Ydoc documents, when I use yXmlFragment.toJSON() method, two different browsers can print the same content, but this content can not be rendered in Prosemirror. Here is the result of my breakpoint debugging, but I don’t know how to solve it.

That is strange. Check also you have no duplicate yjs packages installed locally - those mess up the instanceof checks (and nowadays it should log an error in the console).

EDIT: But that screenshot above is from a failing check or succeeding?

The result is false, and I suspect that this may be the cause of the problem

When I use the same data to apply the update, the Prosemirror document displays fine, but when I use a custom Provider, it prompts this error.

  const ydoc = new Y.Doc()
  const yXmlFragment = ydoc.getXmlFragment('prosemirror')
  const provider = new SocketIOProvider('ws://localhost:3182', ydoc, {
    autoConnect: true,
      cid: xxx,
      token: '123'

  provider.socket.on("sync-update", (data) => console.log('remote update', new Uint8Array(data)));

I would debug it step by step. First, I suggest copying WebsocketProvider locally with similar setup as your SocketIOProvider GitHub - yjs/y-websocket: Websocket Connector for Yjs

If it works, then replace it part by part until you arrive at the same SocketIOProvider you had originally.

Thanks for the suggestion, I will try it.

I know the reason!I used npm link to debug my provider,and it will load new yjs lib.

1 Like

It was duplicate packages? In any case, great to hear!