mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 17:45:53 +01:00
fix(server): close the postgres client before embedded-postgres teardown
The native Codex vertical-slice suite stopped the embedded database before ending its own postgres.js client. Stopping the server tears the TCP connection down under the still-open client, and a batched write the driver scheduled via setImmediate can then fire after the socket dropped -- an unhandled "Cannot read properties of null (reading 'write')" that failed the run even though every test passed. Close the client first, matching the fix already applied to the cross-issue-cap postgres suite. Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 file changed
+10
-1
@@ -90,6 +90,7 @@ describeEmbeddedPostgres("native Codex server vertical slice", () => {
|
||||
let temporary: Awaited<ReturnType<typeof startEmbeddedPostgresTestDatabase>> | null = null;
|
||||
let runtimeRoot: string | null = null;
|
||||
let server: Server | null = null;
|
||||
let db: ReturnType<typeof createDb> | null = null;
|
||||
|
||||
beforeAll(async () => {
|
||||
ensureRunnerTestBinaries();
|
||||
@@ -107,13 +108,21 @@ describeEmbeddedPostgres("native Codex server vertical slice", () => {
|
||||
afterAll(async () => {
|
||||
runnerPrpWebSocketInternals.resetForTests();
|
||||
await closeServer(server);
|
||||
// Close the postgres.js pool before stopping the embedded server. Stopping
|
||||
// the server first tears the TCP connection down under the still-open
|
||||
// client, and a batched write the driver scheduled via setImmediate can
|
||||
// then fire after the connection dropped its socket — an unhandled
|
||||
// `Cannot read properties of null (reading 'write')` that fails the run
|
||||
// even though every test passed. `end()` waits for in-flight queries and
|
||||
// closes the sockets from the client side first.
|
||||
await db?.$client.end();
|
||||
await temporary?.cleanup();
|
||||
if (runtimeRoot) await rm(runtimeRoot, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("returns a durable result and resumes the provider session on the next run", async () => {
|
||||
if (!temporary || !runtimeRoot) throw new Error("Vertical-slice fixture was not initialized");
|
||||
const db = createDb(temporary.connectionString);
|
||||
db = createDb(temporary.connectionString);
|
||||
const companyId = randomUUID();
|
||||
const agentId = randomUUID();
|
||||
const issueId = randomUUID();
|
||||
|
||||
Reference in new issue
Block a user