Sync: Add CRDT document size limiting framework#76405
Conversation
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.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| estimateUpdateSizeBytes: jest.fn( | ||
| ( update: { data: string } ) => update.data.length | ||
| ), |
| maxDocumentSizeBytes: 5 * 1024 * 1024, // 5 MB | ||
| maxUpdateSizeBytes: 1 * 1024 * 1024, // 1 MB |
There was a problem hiding this comment.
these can just be defined alongside the other constants in polling-manager.ts
|
|
||
| // Check document size before sending compaction. | ||
| if ( | ||
| estimateUpdateSizeBytes( compactionUpdate ) > |
There was a problem hiding this comment.
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.
|
Opened #76437 instead. |
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
SizeLimitsinterface and'document-too-large'error code to typesTesting Instructions
npm run test:unit packages/syncnpm run test:unit packages/editornpm run lint:js