Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(postgres): clear a pending direct init on disconnect so the manager can open a pool again (#8478)
garrytan31666997845d
diff --git a/src/core/connection-manager.ts b/src/core/connection-manager.tsindex 69a570164a..ad50269187 100644--- a/src/core/connection-manager.ts+++ b/src/core/connection-manager.ts@@ -506,10 +506,10 @@ export class ConnectionManager {const ends: Promise<void>[] = [];this._epoch++;this._sessionInit = null;+ this._directInit = null;if (this._directPool) {ends.push(endPoolBounded(this._directPool));this._directPool = null;- this._directInit = null;}if (this._readPool && !this._readPoolOwnedExternally) {ends.push(endPoolBounded(this._readPool));diff --git a/test/connection-manager.serial.test.ts b/test/connection-manager.serial.test.tsindex 36d6d9dd12..bfef1b971d 100644--- a/test/connection-manager.serial.test.ts+++ b/test/connection-manager.serial.test.ts@@ -625,6 +625,12 @@ describe('ConnectionManager — a direct pool that opens after retire()/disconneexpect((cm as unknown as Internals)._directPool).toBeNull();expect(cm.isKillSwitchActive()).toBe(false);expect(attempts).toBe(route === 'direct' ? 1 : 2);+ if (shutdown === 'disconnect') {+ const next = fakePool();+ (cm as unknown as Internals).initDirectPool = async () => next as unknown as Pool;+ expect(await cm.ddl()).toBe(next as unknown as Pool);+ expect(next.ends).toBe(0);+ }}, 20000);}