Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

chore: preserve teardown safety across the latest dev refresh

Alfredo Lopezd80719b78c57
diff --cc control-api/package-lock.json
index 4e19aa7aa,fe6e679b9..901ef8fa0
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@@ -1,12 -1,12 +1,12 @@@
{
"name": "clerum-control-api",
- "version": "0.1.700",
- "version": "0.1.699",
++ "version": "0.1.701",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.700",
- "version": "0.1.699",
++ "version": "0.1.701",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",
diff --cc control-api/package.json
index 2d2de50fa,be18ec391..43026ba2d
--- a/control-api/package.json
+++ b/control-api/package.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "clerum-control-api",
- "version": "0.1.700",
- "version": "0.1.699",
++ "version": "0.1.701",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --cc control-api/test/services.adminAuthDelete.realPostgres.integration.test.ts
index 666e4b364,601ff4df6..0e688fd68
--- a/control-api/test/services.adminAuthDelete.realPostgres.integration.test.ts
+++ b/control-api/test/services.adminAuthDelete.realPostgres.integration.test.ts
@@@ -3,8 -3,8 +3,9 @@@ import { randomBytes, randomUUID } fro
import { Pool } from 'pg'
import { initDb, pool } from '../src/db.js'
import { deleteControlAdmin } from '../src/services/adminAuthService.js'
+import { endPoolAndWaitForClients } from './helpers/realPostgresTeardown.js'
import './realPostgres.requirement.ts'
+ import { waitForDatabaseConnectionsToClose } from './realPostgresCleanup.ts'
const adminUrl = process.env.CONTROL_API_REAL_PG_ADMIN_URL
const describeRealPostgres = adminUrl ? describe : describe.skip
@@@ -75,15 -75,14 +76,14 @@@ describeRealPostgres('deleteControlAdmi
afterAll(async () => {
querySpy?.mockRestore()
connectSpy?.mockRestore()
+ await endPoolAndWaitForClients(testPool)
if (!adminPool) return
- await adminPool.query(
- `SELECT pg_terminate_backend(pid) FROM pg_stat_activity
- WHERE datname = $1 AND pid <> pg_backend_pid()`,
- [database]
- )
- await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
- await adminPool.end()
+ try {
- await testPool?.end()
+ await waitForDatabaseConnectionsToClose(adminPool, database)
+ await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
+ } finally {
+ await adminPool.end()
+ }
})
// Regression for the plain DELETE /admin/control-admins/:id path (replaceInviter
diff --cc control-api/test/services.controlAdminReplaceInviter.realPostgres.integration.test.ts
index 17210d380,59ca26618..d1a208289
--- a/control-api/test/services.controlAdminReplaceInviter.realPostgres.integration.test.ts
+++ b/control-api/test/services.controlAdminReplaceInviter.realPostgres.integration.test.ts
@@@ -23,8 -23,8 +23,9 @@@ import
createSilentInvitationForTeams,
} from '../src/services/directory/membership.js'
import { retireDesktopUser } from '../src/services/directory/users.js'
+import { endPoolAndWaitForClients } from './helpers/realPostgresTeardown.js'
import './realPostgres.requirement.ts'
+ import { waitForDatabaseConnectionsToClose } from './realPostgresCleanup.ts'
const adminUrl = process.env.CONTROL_API_REAL_PG_ADMIN_URL
const describeRealPostgres = adminUrl ? describe : describe.skip
@@@ -182,15 -182,14 +183,14 @@@ describeRealPostgres('control admin rep
afterAll(async () => {
querySpy?.mockRestore()
connectSpy?.mockRestore()
+ await endPoolAndWaitForClients(testPool)
if (!adminPool) return
- await adminPool.query(
- `SELECT pg_terminate_backend(pid) FROM pg_stat_activity
- WHERE datname = $1 AND pid <> pg_backend_pid()`,
- [database]
- )
- await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
- await adminPool.end()
+ try {
- await testPool?.end()
+ await waitForDatabaseConnectionsToClose(adminPool, database)
+ await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
+ } finally {
+ await adminPool.end()
+ }
})
it('stores replaceInviter and exposes it with the inviter on every invitation read', async () => {
diff --cc control-api/test/services.directory.userRetirement.realPostgres.integration.test.ts
index 9d6d3b350,245b4d5d1..455a46bbc
--- a/control-api/test/services.directory.userRetirement.realPostgres.integration.test.ts
+++ b/control-api/test/services.directory.userRetirement.realPostgres.integration.test.ts
@@@ -4,7 -4,7 +4,8 @@@ import { Pool } from 'pg
import { initDb, pool } from '../src/db.js'
import { retireDesktopUser } from '../src/services/directory/users.js'
import { gfsDesktopOperatorLinkService } from '../src/services/gfsDesktopOperatorLinkService.js'
+import { endPoolAndWaitForClients } from './helpers/realPostgresTeardown.js'
+ import { waitForDatabaseConnectionsToClose } from './realPostgresCleanup.ts'
const adminUrl = process.env.CONTROL_API_REAL_PG_ADMIN_URL
const describeRealPostgres = adminUrl ? describe : describe.skip
@@@ -57,15 -57,14 +58,14 @@@ describeRealPostgres('retireDesktopUse
afterAll(async () => {
corePoolConnectSpy?.mockRestore()
+ await endPoolAndWaitForClients(testPool)
if (!adminPool) return
- await adminPool.query(
- `SELECT pg_terminate_backend(pid) FROM pg_stat_activity
- WHERE datname = $1 AND pid <> pg_backend_pid()`,
- [database]
- )
- await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
- await adminPool.end()
+ try {
- await testPool?.end()
+ await waitForDatabaseConnectionsToClose(adminPool, database)
+ await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
+ } finally {
+ await adminPool.end()
+ }
})
it('persists the legacy deleted outcome and returns it on an identical replay', async () => {