mongodb 6.18.0-dev.20250806.sha.e628296a → 6.18.0-dev.20250814.sha.33d340ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/lib/collection.js +5 -5
  2. package/lib/collection.js.map +1 -1
  3. package/lib/operations/client_bulk_write/client_bulk_write.js +9 -42
  4. package/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -1
  5. package/lib/operations/count.js +8 -4
  6. package/lib/operations/count.js.map +1 -1
  7. package/lib/operations/create_collection.js +17 -20
  8. package/lib/operations/create_collection.js.map +1 -1
  9. package/lib/operations/delete.js +16 -13
  10. package/lib/operations/delete.js.map +1 -1
  11. package/lib/operations/drop.js +13 -6
  12. package/lib/operations/drop.js.map +1 -1
  13. package/lib/operations/estimated_document_count.js +8 -4
  14. package/lib/operations/estimated_document_count.js.map +1 -1
  15. package/lib/operations/execute_operation.js.map +1 -1
  16. package/lib/operations/find_and_modify.js +53 -42
  17. package/lib/operations/find_and_modify.js.map +1 -1
  18. package/lib/operations/indexes.js +16 -11
  19. package/lib/operations/indexes.js.map +1 -1
  20. package/lib/operations/insert.js +0 -13
  21. package/lib/operations/insert.js.map +1 -1
  22. package/lib/operations/list_databases.js +6 -4
  23. package/lib/operations/list_databases.js.map +1 -1
  24. package/lib/operations/rename.js +11 -9
  25. package/lib/operations/rename.js.map +1 -1
  26. package/lib/operations/search_indexes/create.js +12 -9
  27. package/lib/operations/search_indexes/create.js.map +1 -1
  28. package/lib/operations/search_indexes/update.js +12 -5
  29. package/lib/operations/search_indexes/update.js.map +1 -1
  30. package/lib/operations/update.js +23 -20
  31. package/lib/operations/update.js.map +1 -1
  32. package/lib/operations/validate_collection.js +18 -19
  33. package/lib/operations/validate_collection.js.map +1 -1
  34. package/lib/sdam/server.js +25 -15
  35. package/lib/sdam/server.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/collection.ts +7 -22
  38. package/src/operations/client_bulk_write/client_bulk_write.ts +23 -67
  39. package/src/operations/count.ts +11 -11
  40. package/src/operations/create_collection.ts +22 -31
  41. package/src/operations/delete.ts +32 -36
  42. package/src/operations/drop.ts +18 -17
  43. package/src/operations/estimated_document_count.ts +10 -11
  44. package/src/operations/execute_operation.ts +7 -6
  45. package/src/operations/find_and_modify.ts +80 -56
  46. package/src/operations/indexes.ts +17 -26
  47. package/src/operations/insert.ts +0 -20
  48. package/src/operations/list_databases.ts +8 -17
  49. package/src/operations/rename.ts +13 -16
  50. package/src/operations/search_indexes/create.ts +16 -16
  51. package/src/operations/search_indexes/update.ts +16 -11
  52. package/src/operations/update.ts +55 -54
  53. package/src/operations/validate_collection.ts +21 -29
  54. package/src/sdam/server.ts +25 -15
@@ -303,7 +303,30 @@ export class Server extends TypedEventEmitter<ServerEvents> {
303
303
  }
304
304
  }
305
305
 
306
- const cmd = operation.buildCommand(conn, session);
306
+ let reauthPromise: Promise<void> | null = null;
307
+ const cleanup = () => {
308
+ this.decrementOperationCount();
309
+ if (session?.pinnedConnection !== conn) {
310
+ if (reauthPromise != null) {
311
+ // The reauth promise only exists if it hasn't thrown.
312
+ const checkBackIn = () => {
313
+ this.pool.checkIn(conn);
314
+ };
315
+ void reauthPromise.then(checkBackIn, checkBackIn);
316
+ } else {
317
+ this.pool.checkIn(conn);
318
+ }
319
+ }
320
+ };
321
+
322
+ let cmd;
323
+ try {
324
+ cmd = operation.buildCommand(conn, session);
325
+ } catch (e) {
326
+ cleanup();
327
+ throw e;
328
+ }
329
+
307
330
  const options = operation.buildOptions(timeoutContext);
308
331
  const ns = operation.ns;
309
332
 
@@ -325,8 +348,6 @@ export class Server extends TypedEventEmitter<ServerEvents> {
325
348
  options.omitMaxTimeMS = true;
326
349
  }
327
350
 
328
- let reauthPromise: Promise<void> | null = null;
329
-
330
351
  try {
331
352
  try {
332
353
  const res = await conn.command(ns, cmd, options, operation.SERVER_COMMAND_RESPONSE_TYPE);
@@ -360,18 +381,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
360
381
  throw operationError;
361
382
  }
362
383
  } finally {
363
- this.decrementOperationCount();
364
- if (session?.pinnedConnection !== conn) {
365
- if (reauthPromise != null) {
366
- // The reauth promise only exists if it hasn't thrown.
367
- const checkBackIn = () => {
368
- this.pool.checkIn(conn);
369
- };
370
- void reauthPromise.then(checkBackIn, checkBackIn);
371
- } else {
372
- this.pool.checkIn(conn);
373
- }
374
- }
384
+ cleanup();
375
385
  }
376
386
  }
377
387