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

Method endSession

src/sessions.ts:267–291  ·  view source on GitHub ↗

* Frees any client-side resources held by the current session. If a session is in a transaction, * the transaction is aborted. * * Does not end the session on the server. * * @param options - Optional settings. Currently reserved for future use

(options?: EndSessionOptions)

Source from the content-addressed store, hash-verified

265 * @param options - Optional settings. Currently reserved for future use
266 */
267 async endSession(options?: EndSessionOptions): Promise<void> {
268 try {
269 if (this.inTransaction()) {
270 await this.abortTransaction({ ...options, throwTimeout: true });
271 }
272 } catch (error) {
273 // spec indicates that we should ignore all errors for `endSessions`
274 if (error.name === 'MongoOperationTimeoutError') throw error;
275 squashError(error);
276 } finally {
277 if (!this.hasEnded) {
278 const serverSession = this.serverSession;
279 if (serverSession != null) {
280 // release the server session back to the pool
281 this.sessionPool.release(serverSession);
282 // Store a clone of the server session for reference (debugging)
283 this._serverSession = new ServerSession(serverSession);
284 }
285 // mark the session as ended, and emit a signal
286 this.hasEnded = true;
287 this.emit('ended', this);
288 }
289 maybeClearPinnedConnection(this, { force: true, ...options });
290 }
291 }
292 /**
293 * An alias for {@link ClientSession.endSession|ClientSession.endSession()}.
294 */

Callers 15

[Symbol.asyncDispose]Method · 0.95
operations.tsFile · 0.80
cleanupMethod · 0.80
runTestSuiteTestFunction · 0.80
sessions.test.tsFile · 0.80
testFunction · 0.80
testFunction · 0.80
crud.prose.test.tsFile · 0.80

Calls 6

inTransactionMethod · 0.95
abortTransactionMethod · 0.95
squashErrorFunction · 0.90
releaseMethod · 0.80
emitMethod · 0.65

Tested by 2

testFunction · 0.64
testFunction · 0.64