Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(postgres): let a hung trailing COMMIT's discard timer not keep the process alive (#8651)

garrytanf56f6f2a1944
diff --git a/src/core/postgres-engine/bounded-statement.ts b/src/core/postgres-engine/bounded-statement.ts
index 4d602c57c3..bc51e0e9a9 100644
--- a/src/core/postgres-engine/bounded-statement.ts
+++ b/src/core/postgres-engine/bounded-statement.ts
@@ -103,6 +103,7 @@ export async function runDeadlineRead<T>(conn: Sql, deadlineAt: number, run: (tx
gauge.release('reserved');
};
const stuck = setTimeout(() => { reserved.discard(); settle(); }, Math.max(deadlineAt - Date.now(), settleMs));
+ stuck.unref?.();
void reserved.unsafe('COMMIT').execute().then(settle, settle);
}
}