Skip to content

Conversation

@epeicher
Copy link
Contributor

Fix DataCloneError when handling large files by transferring the ArrayBuffer instead of cloning it. This is more efficient and works with detached buffers.

Motivation for the change, related issues

STU-73

Implementation details

Modified the PHPResponse transfer handler's serialize method in api.ts to explicitly transfer the underlying ArrayBuffer instead of cloning it.

Previously, the method returned an empty transferables array, causing Comlink to clone the response data. For large files (e.g., 4.8GB backups), this failed with DataCloneError when the ArrayBuffer had already been transferred/detached upstream. The fix adds data.bytes.buffer to the transferables array, enabling zero-copy transfer regardless of the buffer's prior state. This resolves the serialization error for large file downloads while also improving memory efficiency.

Testing Instructions (or ideally a Blueprint)

  1. Create a site locally for example using Studio
  2. Using the terminal, run the playground cli mounting the Studio folder, for example using this command:
nx dev playground-cli server --mount-before-install=<path-to-studio-site>:/wordpress

Replacing <path-to-studio-site> with the root path of your Studio site, I use the absolute path for that.
4. Open the URL that playground-cli provides and navigate to WP admin, you can take the password from the Studio settings.
5. Install All In One WP Migration plugin.
6. Upload >2GB files to the site, you can use large media files for that.
7. Export site to file using the plugin.
8. Download the file
9. Verify that the file can be downloaded successfully.

…ialization

Fix DataCloneError when handling large files by transferring the ArrayBuffer
instead of cloning it. This is more efficient and works with detached buffers.
@adamziel
Copy link
Collaborator

Oh, really nice ❤️

@adamziel adamziel merged commit ce96566 into WordPress:trunk Dec 15, 2025
33 checks passed
@epeicher epeicher deleted the stu-73-site-larger-than-2gb-cant-be-exported-using-all-in-one-wp branch December 15, 2025 12:22
@wojtekn
Copy link
Collaborator

wojtekn commented Dec 15, 2025

Nice catch @epeicher !

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