Skip to content

Commit 79efb7c

Browse files
committed
Refactor BaseConnectionPool empty method
Signed-off-by: Bandini Bhopi <[email protected]>
1 parent 9b44c61 commit 79efb7c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1818
- Bumps `eslint-config-prettier` from 8.8.0 to 9.0.0
1919
### Changed
2020
- Make handling of long numerals an option that is disabled by default ([#557](https://github.com/opensearch-project/opensearch-js/pull/557))
21+
- Refactor BaseConnectionPool empty method so that callback will always get called even when there is no connection ([#585](https://github.com/opensearch-project/opensearch-js/pull/585))
2122
### Deprecated
2223
### Removed
2324
### Fixed

Diff for: lib/pool/BaseConnectionPool.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,14 @@ class BaseConnectionPool {
150150
let openConnections = this.size;
151151
this.connections.forEach((connection) => {
152152
connection.close(() => {
153-
if (--openConnections === 0) {
154-
this.connections = [];
155-
this.size = this.connections.length;
156-
callback();
157-
}
153+
openConnections--;
158154
});
159155
});
156+
if (openConnections === 0) {
157+
this.connections = [];
158+
this.size = this.connections.length;
159+
callback();
160+
}
160161
}
161162

162163
/**

0 commit comments

Comments
 (0)