Skip to content

Build from source

The npm package bundles prebuilt binaries for Linux x64/arm64 (glibc and musl), macOS x64/arm64 and Windows x64. Build from source on other platforms, or to work on lagless itself.

  • Rust (stable) and Cargo
  • Node.js 18+
  • pnpm
Terminal window
pnpm install
pnpm build # native module (napi) + TypeScript wrapper (dist/)
pnpm typecheck # lib, tests and bench
pnpm test # loopback e2e + 50-peer load test against node-datachannel
pnpm test:soak # memory/thread leak soak with peer churn (SOAK_SECONDS, SOAK_PEERS)
pnpm test:rust # pacer unit tests

The WebRTC stack is stasadance/rtc, branch lagless: upstream webrtc-rs/rtc v0.21.1 (0fbcaa7) plus 4 commits. Its 214 rtc-sctp tests run there with cargo test -p rtc-sctp.

commit what
1 rtc-sctp tests bind IPv4 loopback (CI containers without IPv6)
2 RACK-TLP loss detection (RFC 8985), behind TransportConfig::with_rack / SettingEngine::with_sctp_rack, plus a configurable RTO min
3 Losses of chunks that won’t be retransmitted don’t cut cwnd
4 Association::transport_stats() / RTCPeerConnection::sctp_transport_stats(): srtt, min RTT, cwnd, in-flight/pending/acked bytes, RACK and T3 counters
Terminal window
pnpm build && pnpm exec playwright install chromium # or CHROMIUM_PATH=/path/to/chrome
node bench/run.mts rtc+rack+pace 1 5 1 45 # kind gate loss% seed seconds [rttMs]
bench/matrix.sh results.jsonl rtc+rack+pace rtc ndc
bench/scenarios.sh scenarios.jsonl # bufferbloat, 8-peer contention, bursty loss, jitter, RTT swing, 400 ms
node bench/summarize.mts results.jsonl

Flags for one run: --peers N, --rate KBps (shared server-to-client bottleneck), --up-rate, --queue ms, --ge p,r,lossBad[,lossGood] (Gilbert-Elliott bursty loss), --jitter ms, --swing ms,periodS, --label name.

Kinds: ndc (node-datachannel), rtc (lagless, gate only), +rack, +pace, +rto<ms>.

Bump version in package.json and merge to main. The release workflow builds all seven targets, puts every binary in the one lagless package and publishes it to npm with trusted publishing (no token, no tag). A push whose version is already on npm publishes nothing.