atproto relay implementation in zig zlay.waow.tech
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix segfault: handle client close frame gracefully

without a clientClose handler, the websocket library tries to write a
close reply back to the client. if the socket is already dead, this
panics in std/net.zig drain (exit code 139 / SIGSEGV).

add clientClose to the broadcaster Handler so we control the close
path and catch write errors instead of crashing the process.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

zzstoatzz 1c01190e bb5cb1fb

+11
+11
src/broadcaster.zig
··· 581 581 // relay consumers are read-only 582 582 } 583 583 584 + /// handle client-initiated close frame. without this, the websocket 585 + /// library tries to write a close reply which can panic if the socket 586 + /// is already dead (unreachable in std/net.zig drain). 587 + pub fn clientClose(self: *Handler, _: []const u8) !void { 588 + if (self.consumer) |c| { 589 + c.alive.store(false, .release); 590 + c.cond.signal(); 591 + } 592 + self.conn.close(.{}) catch {}; 593 + } 594 + 584 595 pub fn close(self: *Handler) void { 585 596 if (self.consumer) |c| self.broadcaster.removeConsumer(c); 586 597 }