Scope
TCPServer and UDPServer move from ws + node:https to Bun.serve()
- The TLS/non-TLS branches collapse into one call with optional
tls; the duplicated
startWebSocketServer helper is removed
- Per-connection state moves to
ws.data; server.requestIP() replaces
request.socket.remoteAddress
- Remove
ws and @types/ws; add @types/bun
tsconfig.server.json gets types: ["bun"] and skipLibCheck: true (the latter is a
real loosening — node-datachannel's .d.ts conflicts with the DOM lib)
__clear() teardown is implemented so the servers actually release their ports
- Tests move from
vi.mock("ws") to vi.stubGlobal("Bun", …) — Bun is a global, so
vi.mock cannot intercept it
Breaking change
@nanoforge-dev/network/server now requires Bun and no longer runs on Node, as accepted
in this issue. The client entry point is unaffected. Note @nanoforge-dev/loader-server
is currently built with bun build --target node, so it must move before nf start
works with this.
Scope boundary
Bun.serve() speeds up signalling only. The UDP data channel is libdatachannel's own
C++ sockets and never touches Bun's networking — benchmarked at 20k msgs × 200 B, three
runs each: Bun 52.8/49.8/51.5k msg/s vs Node 46.8/48.3/49.9k msg/s. The ranges overlap;
there is no meaningful difference on the media path.
Scope
TCPServerandUDPServermove fromws+node:httpstoBun.serve()tls; the duplicatedstartWebSocketServerhelper is removedws.data;server.requestIP()replacesrequest.socket.remoteAddresswsand@types/ws; add@types/buntsconfig.server.jsongetstypes: ["bun"]andskipLibCheck: true(the latter is areal loosening — node-datachannel's
.d.tsconflicts with theDOMlib)__clear()teardown is implemented so the servers actually release their portsvi.mock("ws")tovi.stubGlobal("Bun", …)—Bunis a global, sovi.mockcannot intercept itBreaking change
@nanoforge-dev/network/servernow requires Bun and no longer runs on Node, as acceptedin this issue. The client entry point is unaffected. Note
@nanoforge-dev/loader-serveris currently built with
bun build --target node, so it must move beforenf startworks with this.
Scope boundary
Bun.serve()speeds up signalling only. The UDP data channel is libdatachannel's ownC++ sockets and never touches Bun's networking — benchmarked at 20k msgs × 200 B, three
runs each: Bun 52.8/49.8/51.5k msg/s vs Node 46.8/48.3/49.9k msg/s. The ranges overlap;
there is no meaningful difference on the media path.