[PHP WASM] Transfer ArrayBuffer instead of cloning in PHPResponse serialization #3036
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
PHPResponsetransfer handler'sserializemethod inapi.tsto explicitly transfer the underlyingArrayBufferinstead 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
DataCloneErrorwhen the ArrayBuffer had already been transferred/detached upstream. The fix addsdata.bytes.bufferto 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)
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.