Skip to main content
This covers common database connection-related problems in Sonamu and how to resolve them.

DB Connection Resource Leak

Symptoms

Or
This occurs when running development server for a long time or repeating Fixture operations.

Cause

When DB connections are created and an error occurs, destroy() is not called, causing connections to accumulate without being cleaned up. Problematic code pattern:

Solutions

1. Use try-finally Pattern

2. Clean Up Multiple DB Connections

3. Check Current Connection Count

To check current connection status in PostgreSQL:

Prevention

  • Always use try-finally when creating DB connections directly
  • Using BaseModel methods automatically manages connections
  • Use FixtureManager methods for Fixture operations (includes automatic cleanup)

Connection Configuration Error

Symptoms

Causes

  1. PostgreSQL server is not running
  2. DB configuration in .env file is incorrect
  3. Port number is wrong

Solutions

1. Check PostgreSQL Running

2. Check Connection Information

Check .env file:

3. Manual Connection Test

If successful, psql prompt appears after password input.

Timeout Error

Symptoms

Causes

  1. DB connection pool exhausted
  2. Long-running queries holding connections
  3. Connection pool settings too small

Solutions

1. Adjust Connection Pool Settings

sonamu.config.ts:

2. Check Long-Running Queries

3. Check Uncommitted Transactions

Permission Error

Symptoms

Solution

Test Environment DB Conflict

Symptoms

Or

Causes

  • Previous test didn’t terminate properly, leaving test DB
  • Multiple test processes running simultaneously

Solutions

1. Force Delete Test DB

2. Isolate Test Execution

package.json:

3. Check Test Setup/Teardown