MCPcopy
hub / github.com/mongodb/node-mongodb-native / release

Method release

src/sessions.ts:1139–1160  ·  view source on GitHub ↗

* Release a session to the session pool * Adds the session back to the session pool if the session has not timed out yet. * This method also removes any stale sessions from the pool. * * @param session - The session to release to the pool

(session: ServerSession)

Source from the content-addressed store, hash-verified

1137 * @param session - The session to release to the pool
1138 */
1139 release(session: ServerSession): void {
1140 const sessionTimeoutMinutes = this.client.topology?.logicalSessionTimeoutMinutes ?? 10;
1141
1142 if (this.client.topology?.loadBalanced && !sessionTimeoutMinutes) {
1143 this.sessions.unshift(session);
1144 }
1145
1146 if (!sessionTimeoutMinutes) {
1147 return;
1148 }
1149
1150 this.sessions.prune(session => session.hasTimedOut(sessionTimeoutMinutes));
1151
1152 if (!session.hasTimedOut(sessionTimeoutMinutes)) {
1153 if (session.isDirty) {
1154 return;
1155 }
1156
1157 // otherwise, readd this session to the session pool
1158 this.sessions.unshift(session);
1159 }
1160 }
1161}
1162
1163/**

Callers 5

sessions.test.tsFile · 0.80
endSessionMethod · 0.80
makeClientMetadataFunction · 0.80

Calls 3

unshiftMethod · 0.80
pruneMethod · 0.80
hasTimedOutMethod · 0.80

Tested by

no test coverage detected