-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ottypes/docs spec is not supported correctly wrt (de)serialisation #214
Comments
The contract for custom (de)serialization of ot types in ShareDB differs from the spec you reference. This was done for good reason and it is "documented" here #108. I'm always glad to hear of new use cases for custom ot types. At Retrium we have been using custom ot types with custom serialization for about three years in production and I assure you the current implementation in sharedb works without fail. |
From reading ShareDB source code, I see the differences affect the following functions:
As I understand, the reason is performance, which is a good reason indeed. :-) However, couldn't the same benefits be achieved while maintaining compatibility with ottypes/docs? For example, add a new optional function to the spec:
I never questioned that it works. I just pointed out that it implements a different spec than the one referenced in the readme file. IMHO, the written ottypes/docs spec is clearer and simpler than the implied spec implemented by ShareDB, so I'd still argue for maintaining compatibility with ottypes/docs. |
Spec: https://github.com/ottypes/docs#standard-properties
First of all, according to the spec,
initialData
,snapshot
anddata
may all be completely different data types in the following function specscreate([initialData]) -> snapshot
,serialize(snapshot) -> data
,deserialize(data) -> snapshot
. text-tp2 is an example of such a type. Please note also thatcreate([initialData]) -> snapshot
returns a non-serialized snapshot.Secondly,
apply(snapshot, op) -> snapshot'
expects a non-serialized snapshot as the first parameter. Again, text-tp2 is an example of a type which relies on the first param being a non-serialized snapshot.I found a number of problems in ShareDB related to the above:
initialData
, instead of asnapshot
, in tryCompose. I have already opened a PR with a fix.deserialize
here.create
already returns a non-serialized snapshot.serialize
and relies on the OT types to definetoJSON
instead. This is not documented anywhere and violates the spec.The text was updated successfully, but these errors were encountered: