Skip to content

feat(puter.js): transferables in AppConnection.postMessage - #3776

Open
r58Playz wants to merge 1 commit into
HeyPuter:mainfrom
r58Playz:add-appconnection-transferables
Open

feat(puter.js): transferables in AppConnection.postMessage#3776
r58Playz wants to merge 1 commit into
HeyPuter:mainfrom
r58Playz:add-appconnection-transferables

Conversation

@r58Playz

@r58Playz r58Playz commented Sep 5, 2026

Copy link
Copy Markdown
Member

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.

`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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants