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.
Requirements
Section titled “Requirements”- Rust (stable) and Cargo
- Node.js 18+
- pnpm
Build and test
Section titled “Build and test”pnpm installpnpm build # native module (napi) + TypeScript wrapper (dist/)pnpm typecheck # lib, tests and benchpnpm test # loopback e2e + 50-peer load test against node-datachannelpnpm test:soak # memory/thread leak soak with peer churn (SOAK_SECONDS, SOAK_PEERS)pnpm test:rust # pacer unit testsThe rtc fork
Section titled “The rtc fork”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 |
Benchmarks
Section titled “Benchmarks”pnpm build && pnpm exec playwright install chromium # or CHROMIUM_PATH=/path/to/chromenode 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 ndcbench/scenarios.sh scenarios.jsonl # bufferbloat, 8-peer contention, bursty loss, jitter, RTT swing, 400 msnode bench/summarize.mts results.jsonlFlags 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>.
Release
Section titled “Release”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.