Data duplication on server restart #318
-
Data duplication while server restarting. Steps to reproduce:
async onLoadDocument(data) {
if (data.document.isEmpty('content')) {
const insertDelta = slateNodesToInsertDelta([
{ type: 'p', children: [{ text: 'testing' }] },
] as any);
const sharedRoot = data.document.get('content', Y.XmlText) as Y.XmlText;
sharedRoot.applyDelta(insertDelta);
}
return data.document;
}, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
I'm guessing from your previous issue/question you are only persisting the serialized version of the yjs document. You'll have to store the actual yjs document state inside some sort of DB. Hocuspocus offers multiple extensions to do it for you, like import { Server } from '@hocuspocus/server'
import { Redis } from '@hocuspocus/extension-redis'
const server = Server.configure({
extensions: [
new Redis({
// [required] Hostname of your Redis instance
host: '127.0.0.1',
// [required] Port of your Redis instance
port: 6379,
})
],
})
server.listen() |
Beta Was this translation helpful? Give feedback.
-
Sadly hocuspocus is currently still sponsorware (will be fully oss once v1.0 is released), so to get access to the docs you'll have to sponsor @ueberdosis on GitHub I believe. |
Beta Was this translation helpful? Give feedback.
-
I'm facing this issue if I leave the page editor open for 30mins+. I'm using hocuspocus as well, pretty similar setup as the example. Is there maybe a strategy missing to handle reconnections after some timeout? I was only able to reproduce when I deliberately turn off my wifi as the chrome tools network throttle doesn't work for an open socket. The socket is good to begin with, I turn off the wifi. The provider starts to retry the connection until I turn on the wifi and it succeds, this then sends back the same doc and the client merges it. Do you have any suggestions for this problem? Thank you, for this amazing tool btw. |
Beta Was this translation helpful? Give feedback.
-
Hi @BitPhinix I have a similar issue when using
Seems like something that should be idempotent is not. Any idea what's going on here? |
Beta Was this translation helpful? Give feedback.
-
The problem is not resolved. Its still happening added |
Beta Was this translation helpful? Give feedback.
I'm guessing from your previous issue/question you are only persisting the serialized version of the yjs document. You'll have to store the actual yjs document state inside some sort of DB. Hocuspocus offers multiple extensions to do it for you, like
@hocuspocus/extension-redis
: