Skip to content

[BUG] pool.close fails when callback is provided; causing memory leak #427

Description

@larstbone

In function pool.close(), if a callback is provided, the subsequent loop on "freeConnections" does nothing because that structure was previously zeroed out earlier in the function. The foreach should be performed on the local const "connections" which was a copy of "freeConnections" before being zeroed out.

The tests do not catch this because they validate that "freeConnections" is zero afterwards, which it is. But because of the bug, the actual connections were not closed.

The code block that runs when callback is provided

NOW
async.each(this.freeConnections, (connection, cb) => {
connection.nativeClose((error) => {
this.poolSize--;
cb(error);
});
}, error => callback(error));

SHOULD BE
async.each(connections, (connection, cb) => {
connection.nativeClose((error) => {
this.poolSize--;
cb(error);
});
}, error => callback(error));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions