Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[BUG] Connection pool grows correctly but never shrinks back

Open
#445 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, node.js
Domain
database

Research direction

Start with the pool options and lifecycle documentation in README.md, then reproduce the issue using pool.query() and pool.connect() with shrink: true. Check whether the documented behavior matches the observed pool.poolSize after load; done means either deterministic shrinking works or the behavior and cleanup controls are clearly documented.

Written by the indexing model from the issue text.

Description

Describe your system

  • odbc Package Version: 2.4.8
  • ODBC Driver: IBM DB2 ODBC DRIVER
  • Database Name: DB2
  • Database OS: IBM i (AS/400)
  • Node.js Version: 18.17.1
  • Node.js OS: IBM i

Describe the bug
When using the built-in connection pool with shrink: true, the pool grows beyond initialSize under load but does not shrink back once the load is gone. After all queries have completed and all connections have been released, pool.poolSize remains permanently greater than initialSize, even after a long idle period.

This behavior occurs both when using pool.query() and when explicitly acquiring and releasing connections using pool.connect() and connection.close().

Expected behavior
With shrink: true, once all connections are released and the system becomes idle, the pool should eventually shrink back to initialSize, or at least have a documented, deterministic behavior regarding when or if shrinking occurs.

To Reproduce

  1. Create a pool with the following options:
    const pool = await odbc.pool({
      connectionString,
      initialSize: 2,
      incrementSize: 1,
      maxSize: 20,
      shrink: true
    });
    
    
  2. Run multiple queries in parallel to force the pool to grow
await Promise.all(
Array.from({ length: 10 }, () =>
  pool.query("SELECT 1")
)
);

#or using explicit connections:

const conn = await pool.connect();
await conn.query("SELECT 1");
await conn.close();
  1. Wait until all queries have completed.
  2. Log pool.poolSize

Additional context
Calling connection.close() seems to only return the connection to the pool and does not close the actual database connection. There does not appear to be a documented idle timeout or automatic cleanup of extra connections. As a result, once the pool grows beyond initialSize, it stays larger even when the application is idle. This makes it hard to control the total number of open database connections.

Is this behavior expected by design? If so, it would be helpful to clarify this in the documentation or provide a deterministic way to shrink or evict idle connections.

Dominant language
JavaScript
Stars
158
Forks
92
Avg merge
4d 19h
Merged PRs (30d)
5

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from IBM/node-odbc

All issues in IBM/node-odbc

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.