Merge pull request #35571 from overleaf/mg-increase-max-string-size

Bump backend OT/history processing limit (MAX_STRING_LENGTH) to 3MB

GitOrigin-RevId: ed64fe5522c45b1ace221a01daa2ae70939816f9
This commit is contained in:
Malik Glossop
2026-09-17 11:35:54 +00:00
committed by Copybot
parent cca0f9b518
commit 73068f10ee
2 changed files with 10 additions and 1 deletions
@@ -45,9 +45,13 @@ class TextOperation extends EditOperation {
/**
* Length of the longest file that we'll attempt to edit, in characters.
*
* Backend OT/history processing limit. Incoming uploads/edits are separately
* capped at 2MB via `max_doc_length`; this higher ceiling lets legacy updates
* with larger OT results flow through history instead of throwing TooLongError.
*
* @type {number}
*/
static MAX_STRING_LENGTH = 2 * Math.pow(1024, 2)
static MAX_STRING_LENGTH = 3 * Math.pow(1024, 2)
static UnprocessableError = UnprocessableError
static ApplyError = ApplyError
static InvalidInsertionError = InvalidInsertionError
@@ -332,6 +332,11 @@ class HistoryOTAdapter {
handleUpdateFromCM(transactions: readonly Transaction[]) {
for (const transaction of transactions) {
// TODO: unlike the sharejs adapter above, this only checks visible
// length. When history-ot is enabled, add the retained tracked-deletes
// length here too (as #20052 did for sharejs) — otherwise total stored
// content (visible + tracked deletes) can exceed the backend cap
// (TextOperation.MAX_STRING_LENGTH) and fail with a 422.
if (
this.maxDocLength &&
transaction.changes.newLength >= this.maxDocLength