Skip to content

feat(transport): add MessageChannel transport backend with transferable objects#126

Open
hristoterezov wants to merge 4 commits intomasterfrom
feat/message-channel-transport-backend
Open

feat(transport): add MessageChannel transport backend with transferable objects#126
hristoterezov wants to merge 4 commits intomasterfrom
feat/message-channel-transport-backend

Conversation

@hristoterezov
Copy link
Copy Markdown
Member

Summary

  • Adds a new MessageChannelTransportBackend that uses the MessageChannel API for communication between windows, providing a more efficient and secure alternative to the existing postMessage-based backend.
  • Extends the transport layer (Transport.ts, ITransportBackend) to support the Transferable objects pattern, enabling zero-copy transfer of ArrayBuffer, MessagePort, and other transferable types across window boundaries.
  • The new backend supports scoped channel initialization, allowing multiple independent channels on the same window.

Test plan

  • Verify MessageChannelTransportBackend can establish a channel between two windows (creator and receiver sides)
  • Verify sendEvent with transferable objects transfers ownership correctly
  • Verify request/response callbacks pass transferable objects through
  • Verify dispose() properly cleans up ports and event listeners
  • Verify scoped channels don't interfere with each other
  • Run npm run build to ensure TypeScript compilation succeeds
  • Run npm test to ensure no regressions
  • Run npm run lint to ensure no linting errors

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b9b2430) to head (142f9c7).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #126   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines         1870      1870           
  Branches        47        47           
=========================================
  Hits          1870      1870           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b9b2430...142f9c7. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hristoterezov hristoterezov force-pushed the feat/message-channel-transport-backend branch from 160cca3 to 7acc6a1 Compare April 13, 2026 23:13
…sferable objects support

Enable efficient transfer of binary data and ports between windows by
adding a MessageChannel API backend and extending the transport layer
to support the Transferable objects pattern (ArrayBuffer, MessagePort, etc.).
Rely on MessagePort's native buffering instead of a noop forwarder so
that messages received before the consumer calls setReceiveCallback are
preserved by the port itself. Assigning onmessage implicitly starts the
port, so we only wire it once a real callback is set.
@hristoterezov hristoterezov force-pushed the feat/message-channel-transport-backend branch from 7acc6a1 to 66b7bdc Compare April 23, 2026 15:08
@hristoterezov hristoterezov marked this pull request as ready for review April 27, 2026 21:52
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.

1 participant