Skip to content

Sync: Add CRDT document size limiting framework#76405

Closed
pkevan wants to merge 1 commit into
trunkfrom
pkevan/crdt-doc-size-limits
Closed

Sync: Add CRDT document size limiting framework#76405
pkevan wants to merge 1 commit into
trunkfrom
pkevan/crdt-doc-size-limits

Conversation

@pkevan
Copy link
Copy Markdown
Contributor

@pkevan pkevan commented Mar 11, 2026

Summary

Add a framework for sync providers to declare and enforce maximum document and update sizes. Prevents oversized payloads from being transmitted, protecting against HTTP payload failures and timeouts.

Changes

  • Add SizeLimits interface and 'document-too-large' error code to types
  • Implement size estimation utility for updates
  • Thread size limits through HTTP polling provider and enforce in polling manager
  • Set default limits (5MB document, 1MB per update)
  • Add user-facing error message and tests

Testing Instructions

  1. Run unit tests: npm run test:unit packages/sync
  2. Verify error message tests: npm run test:unit packages/editor
  3. Check formatting: npm run lint:js
  4. Manual test: Create post with large content to see modal with "Document too large" when limits exceeded (can set very low limits for testing)

Add a framework for sync providers to declare and enforce maximum document and update sizes. Includes size estimation, enforcement in the polling manager, default limits, and user-facing error messages. Prevents oversized payloads from being transmitted, protecting against HTTP payload failures and timeouts.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 11, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: pkevan <paulkevan@git.wordpress.org>
Co-authored-by: chriszarate <czarate@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Comment on lines +55 to +57
estimateUpdateSizeBytes: jest.fn(
( update: { data: string } ) => update.data.length
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can requireActual

Comment on lines +23 to +24
maxDocumentSizeBytes: 5 * 1024 * 1024, // 5 MB
maxUpdateSizeBytes: 1 * 1024 * 1024, // 1 MB
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can just be defined alongside the other constants in polling-manager.ts


// Check document size before sending compaction.
if (
estimateUpdateSizeBytes( compactionUpdate ) >
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking on the response is too late. We should check on the request payload before it is sent. If a large post is loaded, a large step1 update is a source of trouble.

@ingeniumed
Copy link
Copy Markdown
Contributor

Opened #76437 instead.

@ingeniumed ingeniumed closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants