Garbage collection is forcefully turned on on Hocuspocus server
Closed this issue · 4 comments
Description
On the frontend of my editing app, I instantiate a new HocuspocusProvider
, passing in a yjsDoc
with gc: false
. I can log this on my front-end and confirm garbage collection is indeed turned off. When the doc gets sent to my server (either through store
on a the Database
extension or through the generic onStoreDocument
, the passed in document has document.gc = true
. This is preventing me from properly showing version snapshots :(
Steps to reproduce the bug
Steps to reproduce the behavior:
- Create a basic app with a provider, set
gc
to false. - Set up a basic server, when the document comes in through
onStore
oronStoreDocument
, logdocument.gc
, see that it is set totrue
. If you try to do something likeY.createDocFromSnapshot
an error will be thrown.
Expected behavior
The document comes into the server and has gc
set to false.
Environment?
- operating system: NodeJS
- browser: Any
- mobile/desktop: Desktop
- Hocuspocus version:
"@hocuspocus/extension-database": "^2.4.0",
"@hocuspocus/server": "^2.4.0",
"@hocuspocus/transformer": "^2.4.0",
Please let me know if there's a way around this or if there's anything I'm doing wrong!
+1
I think you just have to disable gc on the server as well, have you tried this?
new Hocuspocus({yDocOptions: {gc: false}})
alternatively, you can do this when loading the ydoc from storage:
ydoc.gc = false
This worked!! Thanks - had no idea this existed
😎 just want to drop here that I wouldn't recommend doing this in the long run, as this will lead to an ever-growing history in the ydoc and will increase the memory and cpu requirements a lot (depending on how big the history got).
So, be careful ;)