feat(puter.js): transferables in AppConnection.postMessage - #3776
Open
r58Playz wants to merge 1 commit into
Open
feat(puter.js): transferables in AppConnection.postMessage#3776r58Playz wants to merge 1 commit into
r58Playz wants to merge 1 commit into
Conversation
`postMessage(message, transfer)` (or `{ transfer }`) moves ArrayBuffers,
MessagePorts, streams and the rest to the target app instead of copying
them. The second argument is optional, so existing callers are unchanged.
The transfer list rides in the message body as well as the real transfer
list: structured clone's memory map keeps those objects identical to the
ones inside `contents`, which is how the desktop picks them out mid-relay
and keeps transferring them onward rather than leaving copies behind. Both
`messageToApp` paths carry it — the direct iframe relay and the connection
path that `launchApp()` between apps actually uses.
The desktop forwards the list as-is and lets postMessage judge it. A list
that arrived through the SDK was already validated by the browser on the
first hop, and validating again here would mean an allowlist of
transferable types that silently downgrades an unrecognised one to a copy.
A bad list only reaches us from an app that hand-wrote the envelope; that
throws without detaching anything, and is caught so it cannot escape
`ipc_listener` as an unhandled rejection.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Salazareo
approved these changes
Sep 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
postMessage(message, transfer)(or{ transfer }) moves ArrayBuffers, MessagePorts, streams and the rest to the target app instead of copying them. The second argument is optional, so existing callers are unchanged.The transfer list rides in the message body as well as the real transfer list: structured clone's memory map keeps those objects identical to the ones inside
contents, which is how the desktop picks them out mid-relay and keeps transferring them onward rather than leaving copies behind. BothmessageToApppaths carry it — the direct iframe relay and the connection path thatlaunchApp()between apps actually uses.The desktop forwards the list as-is and lets postMessage judge it. A list that arrived through the SDK was already validated by the browser on the first hop, and validating again here would mean an allowlist of transferable types that silently downgrades an unrecognised one to a copy. A bad list only reaches us from an app that hand-wrote the envelope; that throws without detaching anything, and is caught so it cannot escape
ipc_listeneras an unhandled rejection.