Skip to content

test: attach error listener to raw pg Pools in remote tests#128

Merged
veksen merged 1 commit intomainfrom
veksen/test-pool-fatals
Apr 22, 2026
Merged

test: attach error listener to raw pg Pools in remote tests#128
veksen merged 1 commit intomainfrom
veksen/test-pool-fatals

Conversation

@veksen
Copy link
Copy Markdown
Member

@veksen veksen commented Apr 22, 2026

Summary

  • Attach no-op pool.on("error", ...) on the five raw new Pool(...) instances in remote.test.ts and remote-controller.test.ts.

Why

pool.end() resolves synchronously once _clients is empty, but the underlying client.end() is still async — the Terminate (X) may not have flushed when the testcontainer is stopped in the finally block. The server then sends FATAL 57P01 to the still-listening idle client, which re-emits on the Pool. Library pools go through wrapPgPool (src/sql/postgresjs.ts:126) which already installs a handler; the raw test Pools didn't, so the error escaped as unhandled and flaked CI even when every assertion passed.

Test plan

  • npm run typecheck
  • npx vitest run src/remote/remote.test.ts src/remote/remote-controller.test.ts (13/13 green, no unhandled errors)

🤖 Generated with Claude Code

pool.end() resolves before the underlying client sockets actually close;
if the testcontainer stops during that gap the server emits a FATAL 57P01
on the still-listening idle client and it escapes as an unhandled error.
Library pools go through wrapPgPool which already attaches a handler, but
the five raw `new Pool(...)` instances in these test files didn't.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query Doctor Analysis

View full run details

2 queries analyzed

2 pre-existing issues

Using assumed statistics (10000000 rows/table). For better results, sync production stats.

@veksen veksen merged commit cadb326 into main Apr 22, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants