You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Snapshot of a version with a mark's start but not its end panics on read ("unclosed style mark") #1165
A snapshot of a version that contains a mark's StyleStart op but not its StyleEnd op can't be decoded. The first read of the text panics in container_wrapper.rs:198 with DecodeError("Decode richtext state failed: unclosed style mark"), and the WASM instance is poisoned after that.
Such versions can only be reached with op-level frontiers, not commit frontiers: a mark writes StyleStart at counter c and StyleEnd at c + 1. checkout at such a version works; forkAt and snapshot export from it don't.
constdoc=newLoroDoc();doc.setPeerId(1);doc.configTextStyle({bold: {expand: "after"}});consttext=doc.getText("t");text.insert(0,"abc");// 0@1..2@1text.mark({start: 1,end: 3},"bold",true);// StyleStart 3@1, StyleEnd 4@1text.insert(3,"Z");// 5@1doc.commit();constfork=doc.forkAt([{peer: "1",counter: 3}]);// has the StyleStart, not the StyleEndfork.getText("t").toDelta();// panicked at crates/loro-internal/src/state/container_store/container_wrapper.rs:198:37:// called `Result::unwrap()` on an `Err` value: DecodeError("Decode richtext state failed: unclosed style mark")
The same panic happens after doc.checkout([{ peer: "1", counter: 3 }]); const bytes = doc.fork().export({ mode: "snapshot" }); when another document imports bytes and reads the text.
export({ mode: "update" }), state-only, and shallow-snapshot at that version work (a shallow snapshot moves its root to a critical version).
Expected
Either the snapshot writer closes the style or leaves it out, or the decoder accepts an unclosed start anchor (the style isn't applied until its end anchor is included, as checkout already shows), or import returns Err. It shouldn't panic on the first read.
Context
Found in the second review of #1136/#1137. Since #1137, loro.js writes this state in Rust's layout, so a loro.js snapshot of such a version makes Rust panic the same way. loro.js itself reads it back.
Activity
fix: accept a style start without its end in snapshots (#1165)
fix: issue sweep (#1118, #1162, #1155, #1165, #1156, #1164, #1157, #1154