fix: buffer operations in Stale/StaleWithBuffer instead of throwing (#6342)

When 5+ users edit concurrently, revision gaps trigger the Stale state
which throws 'Ignored server-side change.' on incoming operations. This
causes document divergence, silent data corruption, and eventually
force-resets that discard local edits.

Changes:
- Stale/StaleWithBuffer.applyServer: buffer incoming operations instead
  of throwing, apply them sequentially after missing ops arrive
- Stale.applyClient: carry pendingOps to StaleWithBuffer on transition
- editor-socketio-server: retry-based force-reset (3 failures) instead
  of immediate nuclear reset on any OT error
- hex2rgb: defensive null checks for old non-hex color records

Signed-off-by: bxff <51504045+bxff@users.noreply.github.com>
This commit is contained in:
bxff
2026-03-16 15:16:47 +08:00
committed by Philip Molares
parent f51f8dcc19
commit 65bf11554a
5 changed files with 90 additions and 10 deletions

View File

@@ -1,12 +1,17 @@
function hex2rgb (hex) {
if (!hex || typeof hex !== 'string') return { red: 0, green: 0, blue: 0 }
if (hex[0] == '#') hex = hex.substr(1)
if (hex.length == 3) {
var temp = hex
hex = ''
temp = /^([a-f0-9])([a-f0-9])([a-f0-9])$/i.exec(temp).slice(1)
var match = /^([a-f0-9])([a-f0-9])([a-f0-9])$/i.exec(temp)
if (!match) return { red: 0, green: 0, blue: 0 }
temp = match.slice(1)
for (var i = 0; i < 3; i++) hex += temp[i] + temp[i]
}
var triplets = /^([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i.exec(hex).slice(1)
var result = /^([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/i.exec(hex)
if (!result) return { red: 0, green: 0, blue: 0 }
var triplets = result.slice(1)
return {
red: parseInt(triplets[0], 16),
green: parseInt(triplets[1], 16),