mirror of
https://github.com/livekit/livekit.git
synced 2026-09-15 23:56:10 +00:00
ListenWebTransport ran wt.Serve on a goroutine per socket and returned a stop func calling wt.Close. Serve takes a reference on the server's refCount WaitGroup and Close waits on it, so the pair breaks the WaitGroup's own rule that an Add starting from zero must happen before a Wait. The race detector models that rule as a read of wg.sema in Add against a write in Wait, and reports it whenever Wait observes a non-zero counter: a listener stopped before its serve goroutine has run at all, which is every test that builds a stack and tears it down without a worker connecting. sync is compiled without instrumentation, so the report names the two ListenWebTransport call sites with no frame in between. webtransport-go v0.13.0 carries the same code. The accept loop moves here. quic.ListenEarly builds the listener Serve would have built, with the datagram and partial-delivery options the session layer requires, and each connection goes to Server.ServeQUICConn, which touches no part of that WaitGroup. The stop func keeps the order Close established: Close first, so every CONNECTION_CLOSE frame is transmitted while the sockets are still open, then the accept loops are cancelled and drained, then the listeners and sockets close. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>