Dev.Lib
arrow_backBack to Blogs
LEVEL_066.8June 27, 20261 min read

Transferable objects

Web Security

`postMessage` can transfer ArrayBuffer ownership zero-copy — sender neutered after transfer.

Summary

postMessage can transfer ArrayBuffer ownership zero-copy — sender neutered after transfer. Structured clone duplicates for non-transferables. Workers + transfer for large binary without copy cost. Detached buffer access throws — coordinate lifecycle.

Code example

const buffer = new ArrayBuffer(1024 * 1024);
worker.postMessage({ buffer }, [buffer]);
// buffer.byteLength === 0 in sender after transfer

Key points

  • postMessage can transfer ArrayBuffer ownership zero-copy — sender neutered after transfer.
  • Structured clone duplicates for non-transferables.
  • Workers + transfer for large binary without copy cost.
  • Detached buffer access throws — coordinate lifecycle.

Further reading

Related concepts