Skip to content

feat(NODE-4691): interrupt in-flight operations on heartbeat failure #3457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use checkIn in favor of manually emitting events
  • Loading branch information
baileympearson committed Nov 28, 2022
commit 408401809b12f5c898c85ad11cbae68463e2953b
9 changes: 4 additions & 5 deletions src/cmap/connection_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
* @param connection - The connection to check in
*/
checkIn(connection: Connection): void {
if (!this[kCheckedOut].has(connection)) {
return;
}
const poolClosed = this.closed;
const stale = this.connectionIsStale(connection);
const willDestroy = !!(poolClosed || stale || connection.closed);
Expand Down Expand Up @@ -472,12 +475,8 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
private interruptInUseConnections(minGeneration: number) {
for (const connection of this[kCheckedOut]) {
if (connection.generation <= minGeneration) {
this[kCheckedOut].delete(connection);
this.checkIn(connection);
connection.onError(new PoolClearedOnNetworkError(this));
this.emit(
ConnectionPool.CONNECTION_CLOSED,
new ConnectionClosedEvent(this, connection, 'stale')
);
}
}

Expand Down