Skip to content

fix: use logical OR in postgres connection drain loop#1887

Open
LautaroPetaccio wants to merge 2 commits into
mainfrom
fix/postgres-connection-drain
Open

fix: use logical OR in postgres connection drain loop#1887
LautaroPetaccio wants to merge 2 commits into
mainfrom
fix/postgres-connection-drain

Conversation

@LautaroPetaccio

Copy link
Copy Markdown
Contributor

Summary

The connection drain loop in postgres.ts used bitwise OR (|) instead of logical OR (||) to check if the pool still had active connections:

while (!finished && pool.totalCount | pool.idleCount | pool.waitingCount) {

Bitwise OR on integers happens to produce the same truthiness as logical OR for non-negative values (returns 0 only when all are 0), so this worked by accident. Changed to logical OR with proper parentheses for correctness and clarity.

Test plan

  • Verify graceful shutdown still drains connections properly

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.

1 participant