Let an IRC relay finish its queue read when its connection ends (closes #205)
check / check (push) Waiting to run

When an IRC listener connection ends, serve cancels the context its
relay uses. If the cancel came while the relay was reading the queue,
the SQLite driver interrupted the query and reported the connection
broken, and the pool closed its only connection. In the tests that
deletes the in-memory database, so in TestIntegrationKill alice never
got bob's QUIT. In production the new connection runs without
PRAGMA foreign_keys = ON.

The relay now reads the queue without that cancel. It still stops at
its next check of the context.

Model: opus-5-5
This commit is contained in:
2026-10-27 08:13:36 +00:00
parent a7f9bebe6a
commit 892da36ac3
+6 -2
View File
@@ -32,8 +32,12 @@ func (c *Conn) relayMessages(ctx context.Context) {
// still signals waitCh.
waitCh := c.brk.Wait(c.sessionID)
// Drain any available messages.
delivered := c.drainQueue(ctx)
// Drain any available messages. The drain ignores the
// cancel that comes when the connection ends, because a
// query cancelled while it runs leaves the SQLite
// connection marked broken, and the pool closes it. The
// loop still stops on ctx.
delivered := c.drainQueue(context.WithoutCancel(ctx))
if delivered {
c.brk.Remove(c.sessionID, waitCh)