Rebuild: the coordinator stops on SIGTERM

It waited for every chunk in flight, and a connection the server held
back (after killed coordinators left sessions open) waits up to the
10-minute reply timeout: it never seemed to stop. It now waits at most
15 s, then closes all connections, busy ones too; the greeting and login
time out after 30 s. And run() ends with terminate(), as edge:node does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daan MeijerandClaude Opus 5.5 committed 2026-10-09 03:20:11 +02:00
1 parent cae6e4f60d
commit 883d85e91d
3 files changed
+16 -3

No files matched your search

+6 -1
View File
@@ -10,6 +10,7 @@ import { XoverClient } from '#lib/nntp/index'
*/
class NntpPool {
private idle: XoverClient[] = []
private busy = new Set<XoverClient>()
private open = 0
private waiting: ((client: XoverClient) => void)[] = []
@@ -19,6 +20,7 @@ class NntpPool {
async use<T>(work: (client: XoverClient) => Promise<T>): Promise<T> {
const client = await this.acquire()
this.busy.add(client)
let broken = false
try {
return await work(client)
@@ -26,6 +28,7 @@ class NntpPool {
broken = true
throw error
} finally {
this.busy.delete(client)
this.release(client, broken)
}
}
@@ -71,8 +74,10 @@ class NntpPool {
else this.idle.push(client)
}
/** Closes every connection, also those in use: their commands fail. */
async close() {
for (const client of this.idle.splice(0)) client.close()
for (const client of [...this.idle.splice(0), ...this.busy]) client.close()
this.busy.clear()
this.open = 0
}
}