Skip to content

deps(transport-webrtc): replace node-datachannel#3544

Open
mertushka wants to merge 1 commit into
libp2p:mainfrom
mertushka:deps/replace-node-datachannel
Open

deps(transport-webrtc): replace node-datachannel#3544
mertushka wants to merge 1 commit into
libp2p:mainfrom
mertushka:deps/replace-node-datachannel

Conversation

@mertushka

@mertushka mertushka commented Jun 16, 2026

Copy link
Copy Markdown

Description

Replaces node-datachannel with @mertushka/webrtc-node in @libp2p/webrtc.

@mertushka/webrtc-node is a Node.js WebRTC binding that exposes a W3C-compatible WebRTC API surface instead of a package-specific polyfill surface. Version 0.2.0 passes 620 strict Web Platform Tests for WebRTC API behavior and provides the standard objects @libp2p/webrtc already uses in browsers, including RTCPeerConnection, RTCDataChannel, RTCSessionDescription, RTCIceCandidate, RTCCertificate, and standard EventTarget behavior.

This is useful here because the existing Node path had to wrap node-datachannel APIs to inject ICE credentials, map ICE servers, import certificates, work around stale data channel state, and force native peer connection cleanup. With @mertushka/webrtc-node, the Node path can use the standard WebRTC-shaped APIs directly, with explicit nonstandard hooks only where WebRTC Direct needs Node-specific control over ICE credentials, certificate import, UDP muxing, fingerprint verification, and remote fingerprint access.

This removes the node-datachannel-specific compatibility layer and related runtime workarounds now that the replacement exposes the required standard WebRTC APIs plus the nonstandard APIs used by the WebRTC Direct path.

Changes include:

  • replace the node-datachannel dependency with @mertushka/webrtc-node
  • wire the new WebRTC implementation through the Node WebRTC entrypoints
  • keep WebRTC Direct support using nonstandard APIs:
    • configurePeerConnection
    • importCertificate
    • setLocalIceCredentials
    • getRemoteFingerprint
    • IceUdpMuxListener
  • remove node-datachannel-specific peer connection wrappers
  • remove stale readyState/send error workarounds
  • remove node-datachannel GC/closed-state workarounds

Related open PRs

Potentially Fixes/Closes:

Likely requires a rebase:

Verification

  • npm run dep-check -w @libp2p/webrtc
  • npm run build -w @libp2p/webrtc
  • npm run test:node -w @libp2p/webrtc -- --exit
  • npm run test:chrome -w @libp2p/webrtc

@mertushka mertushka requested a review from a team as a code owner June 16, 2026 02:21
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