Session pool follow-ups: minPoolSize: 0, pending waiters on close(), and a failed idle-session close
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- nodejs, typescript
Rechercherichtung
Beginne in BaseSessionPool.ts bei der Behandlung von minPoolSize um die Zeilen 129 und 373, bei close() um Zeile 505 und bei cleanupIdleSessions um Zeile 391. Überprüfe den bestehenden acquire- und cleanup-Ablauf und füge dann gezielte Abdeckung für Pools der Größe null, wartende Anfragen während close() und fehlgeschlagene Schließvorgänge von idle sessions hinzu. Als erledigt gilt, dass jedes Verhalten ein explizites Ergebnis hat und kein waiter oder fehlgeschlagener close stillschweigend aufgegeben wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
Three non-blocking observations about BaseSessionPool that came out of the reviews of #19 and #20. None of them is a crash or a leak on the normal path, so I did not fold them into those PRs; @CritasWang suggested collecting them in a single tracking issue.
Line references are against develop at a8ca4d2.
1. minPoolSize: 0 is silently coerced to 1
BaseSessionPool.ts:129 (and the cleanup floor at :373) read the setting as:
const minSize = this.config.minPoolSize || 1;
0 || 1 is 1, so a caller who explicitly asks for minPoolSize: 0 gets one eagerly created session at init(), and cleanupIdleSessions then keeps one session alive forever rather than letting the pool drain to empty. In most pool implementations 0 means "create nothing up front, and allow the pool to go back to empty when idle", which is a reasonable ask for short-lived or cost-sensitive processes.
If 0 is intended to be legal, ?? instead of || would express it. If it is not intended to be legal, rejecting it in config validation would be clearer than silently changing it.
2. close() clears the wait queue without settling the waiters
close() at :505 ends with this.waitQueue.clear() (:525). The queued entries are the waiter callbacks themselves, so clearing the queue drops them without ever resolving or rejecting their promises.
A caller that is inside await pool.getSession() when another part of the application closes the pool therefore does not fail fast. It stays pending until the acquire timeout fires (waitTimeout, default 60000ms at :290) and then rejects with Timeout waiting for available session (:320) — which points at pool exhaustion rather than at the real cause. Rejecting each queued waiter during close() with a "pool is closed" error would make both the latency and the message correct.
3. A failed session.close() during idle cleanup orphans the connection
cleanupIdleSessions (:391 onward) deliberately removes a session from pool and idleSessions before awaiting close(), which is correct — it prevents a concurrent getSession() from handing out a session that is about to be destroyed. But if close() rejects, the error is logged (:409) and nothing else happens: the session is already out of every pool structure, so its underlying connection is no longer referenced, never retried, and never counted anywhere.
That is not a leak in the common case — the RPC usually fails because the connection is already gone — but a transport-level failure would leave a real socket open with no owner. Keeping the session in a small "failed to close" set for a later retry, or at least counting it in a metric, would make the failure visible.
Not included
The getSession() create-branch race that also came up in the #19 review is already fixed on develop (:266-276 now locates the session by identity instead of shift()ing the front of the idle queue), so there is nothing left to track there.
I am happy to send a PR for any of these — please let me know which are worth changing and whether you would prefer them separately.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 3
- Forks
- 2
- Ø Merge
- 7 Min.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Ähnliche Issues
-
check:passed streams:add
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Fission-AI/OpenSpec#1986 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
nestjs/docs.nestjs.com#3554 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
publicodes/publicodes#868 ·
-
namespace operations
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
EclipseFdn/open-vsx.org#13488 ·
Maintainer antworten meist innerhalb von 2 Tagen