share / share/sharedb

Do not `invert` automatically in `Doc.prototype._rollback`

Open
#442 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6.5k
Forks
456
Avg merge
1d 5h
Merged PRs (30d)
5

Description

Hey ShareDB's team!

While using https://github.com/ottypes/json1 with ShareDB, I found a small problem in Doc.prototype._rollback. It automatically uses JSON1.type.invert but since we don't use invertible operations (our remove ops do not contain the removed data), it does not work.
https://github.com/share/sharedb/blob/fa9179dd565b11e129c1f005de0a7542ef352363/lib/client/doc.js#L950-L957

Moreover JSON1 support for invertible operations and composition is known to not be without flaws.

Do you think we could introduce a configuration option to deactivate this functionality?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/client/doc.js around Doc.prototype._rollback at lines 950-957 and inspect how JSON1.type.invert is invoked. Review the issue's JSON1 invertibility and composition concern before deciding where a configuration option belongs. Done means rollback can avoid automatic inversion for non-invertible operations without breaking existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.