-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Avoid mutating milestone snapshots when building from ops
At the moment, we directly pass our milestone snapshot to `ot.applyOps()`, which [mutates the snapshot][1]. In most Production-grade implementations of the `MilestoneDb`, this is fine, since mutating the in-memory `Snapshot` will have no effect on the underlying database representation. However, this does break the `MemoryMilestoneDb` (eg in tests). In order to fix this, and generally be defensive (eg if db adapters decide to implement an in-memory cache), this change clones the snapshot before calling `ot.applyOps()` on it. [1]: https://github.com/share/sharedb/blob/a5c19b986d65c93abbc9ed11f7a25c0dbaf0788c/lib/ot.js#L172
- Loading branch information
1 parent
a5c19b9
commit 8a52f10
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters