mongodb 6.8.0-dev.20240822.sha.f5254030 → 6.8.0-dev.20240829.sha.6d65ae77

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 (121) hide show
  1. package/lib/beta.d.ts +29 -5
  2. package/lib/beta.js +0 -1
  3. package/lib/beta.js.map +1 -1
  4. package/lib/bson.js.map +1 -1
  5. package/lib/bulk/common.js +9 -11
  6. package/lib/bulk/common.js.map +1 -1
  7. package/lib/change_stream.js +0 -6
  8. package/lib/change_stream.js.map +1 -1
  9. package/lib/client-side-encryption/mongocryptd_manager.js +1 -1
  10. package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
  11. package/lib/cmap/auth/gssapi.js +1 -1
  12. package/lib/cmap/auth/gssapi.js.map +1 -1
  13. package/lib/cmap/auth/mongodb_aws.js.map +1 -1
  14. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +0 -2
  15. package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
  16. package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +0 -2
  17. package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
  18. package/lib/cmap/commands.js.map +1 -1
  19. package/lib/cmap/connection.js +0 -2
  20. package/lib/cmap/connection.js.map +1 -1
  21. package/lib/cmap/connection_pool.js +0 -1
  22. package/lib/cmap/connection_pool.js.map +1 -1
  23. package/lib/cmap/handshake/client_metadata.js +1 -1
  24. package/lib/cmap/handshake/client_metadata.js.map +1 -1
  25. package/lib/cmap/wire_protocol/shared.js.map +1 -1
  26. package/lib/collection.js.map +1 -1
  27. package/lib/connection_string.js +0 -2
  28. package/lib/connection_string.js.map +1 -1
  29. package/lib/constants.js +1 -0
  30. package/lib/constants.js.map +1 -1
  31. package/lib/cursor/abstract_cursor.js +0 -5
  32. package/lib/cursor/abstract_cursor.js.map +1 -1
  33. package/lib/cursor/aggregation_cursor.js.map +1 -1
  34. package/lib/deps.js +8 -0
  35. package/lib/deps.js.map +1 -1
  36. package/lib/error.js +2 -1
  37. package/lib/error.js.map +1 -1
  38. package/lib/gridfs/download.js +0 -3
  39. package/lib/gridfs/download.js.map +1 -1
  40. package/lib/gridfs/upload.js +0 -4
  41. package/lib/gridfs/upload.js.map +1 -1
  42. package/lib/mongo_logger.js +0 -3
  43. package/lib/mongo_logger.js.map +1 -1
  44. package/lib/mongo_types.js +1 -0
  45. package/lib/mongo_types.js.map +1 -1
  46. package/lib/operations/aggregate.js +1 -0
  47. package/lib/operations/aggregate.js.map +1 -1
  48. package/lib/operations/client_bulk_write/command_builder.js +198 -0
  49. package/lib/operations/client_bulk_write/command_builder.js.map +1 -0
  50. package/lib/operations/client_bulk_write/common.js +3 -0
  51. package/lib/operations/client_bulk_write/common.js.map +1 -0
  52. package/lib/operations/execute_operation.js +2 -1
  53. package/lib/operations/execute_operation.js.map +1 -1
  54. package/lib/operations/find_and_modify.js +1 -1
  55. package/lib/operations/find_and_modify.js.map +1 -1
  56. package/lib/operations/insert.js.map +1 -1
  57. package/lib/operations/operation.js +1 -1
  58. package/lib/operations/operation.js.map +1 -1
  59. package/lib/operations/search_indexes/drop.js.map +1 -1
  60. package/lib/resource_management.js +4 -4
  61. package/lib/resource_management.js.map +1 -1
  62. package/lib/sdam/monitor.js +1 -5
  63. package/lib/sdam/monitor.js.map +1 -1
  64. package/lib/sdam/server_description.js.map +1 -1
  65. package/lib/sdam/srv_polling.js +1 -2
  66. package/lib/sdam/srv_polling.js.map +1 -1
  67. package/lib/sessions.js +1 -1
  68. package/lib/sessions.js.map +1 -1
  69. package/lib/sort.js +1 -1
  70. package/lib/sort.js.map +1 -1
  71. package/lib/timeout.js +0 -1
  72. package/lib/timeout.js.map +1 -1
  73. package/lib/transactions.js.map +1 -1
  74. package/lib/utils.js +0 -1
  75. package/lib/utils.js.map +1 -1
  76. package/lib/write_concern.js.map +1 -1
  77. package/mongodb.d.ts +29 -5
  78. package/package.json +23 -25
  79. package/src/beta.ts +1 -1
  80. package/src/bson.ts +1 -2
  81. package/src/bulk/common.ts +12 -9
  82. package/src/change_stream.ts +10 -11
  83. package/src/client-side-encryption/mongocryptd_manager.ts +1 -1
  84. package/src/cmap/auth/gssapi.ts +1 -1
  85. package/src/cmap/auth/mongodb_aws.ts +2 -2
  86. package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +2 -2
  87. package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +2 -2
  88. package/src/cmap/commands.ts +5 -1
  89. package/src/cmap/connection.ts +2 -2
  90. package/src/cmap/connection_pool.ts +0 -1
  91. package/src/cmap/handshake/client_metadata.ts +1 -1
  92. package/src/cmap/wire_protocol/shared.ts +1 -2
  93. package/src/collection.ts +13 -12
  94. package/src/connection_string.ts +1 -2
  95. package/src/constants.ts +1 -0
  96. package/src/cursor/abstract_cursor.ts +0 -5
  97. package/src/cursor/aggregation_cursor.ts +6 -4
  98. package/src/deps.ts +8 -1
  99. package/src/error.ts +2 -3
  100. package/src/gridfs/download.ts +1 -3
  101. package/src/gridfs/upload.ts +1 -6
  102. package/src/mongo_logger.ts +2 -3
  103. package/src/mongo_types.ts +69 -68
  104. package/src/operations/aggregate.ts +2 -1
  105. package/src/operations/client_bulk_write/command_builder.ts +283 -0
  106. package/src/operations/client_bulk_write/common.ts +146 -0
  107. package/src/operations/execute_operation.ts +6 -4
  108. package/src/operations/find_and_modify.ts +1 -1
  109. package/src/operations/insert.ts +1 -2
  110. package/src/operations/operation.ts +5 -8
  111. package/src/operations/search_indexes/drop.ts +4 -1
  112. package/src/resource_management.ts +4 -4
  113. package/src/sdam/monitor.ts +3 -5
  114. package/src/sdam/server_description.ts +5 -6
  115. package/src/sdam/srv_polling.ts +1 -2
  116. package/src/sessions.ts +1 -1
  117. package/src/sort.ts +1 -1
  118. package/src/timeout.ts +0 -1
  119. package/src/transactions.ts +1 -2
  120. package/src/utils.ts +9 -4
  121. package/src/write_concern.ts +2 -2
@@ -44,7 +44,7 @@ const CHANGE_DOMAIN_TYPES = {
44
44
  CLUSTER: Symbol('Cluster')
45
45
  };
46
46
 
47
- const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE];
47
+ const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE] as const;
48
48
 
49
49
  const NO_RESUME_TOKEN_ERROR =
50
50
  'A change stream document has been received that lacks a resume token (_id).';
@@ -680,7 +680,7 @@ export class ChangeStream<
680
680
  // Change streams must resume indefinitely while each resume event succeeds.
681
681
  // This loop continues until either a change event is received or until a resume attempt
682
682
  // fails.
683
- // eslint-disable-next-line no-constant-condition
683
+
684
684
  while (true) {
685
685
  try {
686
686
  const hasNext = await this.cursor.hasNext();
@@ -706,7 +706,7 @@ export class ChangeStream<
706
706
  // Change streams must resume indefinitely while each resume event succeeds.
707
707
  // This loop continues until either a change event is received or until a resume attempt
708
708
  // fails.
709
- // eslint-disable-next-line no-constant-condition
709
+
710
710
  while (true) {
711
711
  try {
712
712
  const change = await this.cursor.next();
@@ -735,7 +735,7 @@ export class ChangeStream<
735
735
  // Change streams must resume indefinitely while each resume event succeeds.
736
736
  // This loop continues until either a change event is received or until a resume attempt
737
737
  // fails.
738
- // eslint-disable-next-line no-constant-condition
738
+
739
739
  while (true) {
740
740
  try {
741
741
  const change = await this.cursor.tryNext();
@@ -850,10 +850,10 @@ export class ChangeStream<
850
850
  this.type === CHANGE_DOMAIN_TYPES.CLUSTER
851
851
  ? (this.parent as MongoClient)
852
852
  : this.type === CHANGE_DOMAIN_TYPES.DATABASE
853
- ? (this.parent as Db).client
854
- : this.type === CHANGE_DOMAIN_TYPES.COLLECTION
855
- ? (this.parent as Collection).client
856
- : null;
853
+ ? (this.parent as Db).client
854
+ : this.type === CHANGE_DOMAIN_TYPES.COLLECTION
855
+ ? (this.parent as Collection).client
856
+ : null;
857
857
 
858
858
  if (client == null) {
859
859
  // This should never happen because of the assertion in the constructor
@@ -884,7 +884,6 @@ export class ChangeStream<
884
884
  private _closeEmitterModeWithError(error: AnyError): void {
885
885
  this.emit(ChangeStream.ERROR, error);
886
886
 
887
- // eslint-disable-next-line github/no-then
888
887
  this.close().then(undefined, squashError);
889
888
  }
890
889
 
@@ -949,7 +948,7 @@ export class ChangeStream<
949
948
 
950
949
  if (isResumableError(changeStreamError, this.cursor.maxWireVersion)) {
951
950
  this._endStream();
952
- // eslint-disable-next-line github/no-then
951
+
953
952
  this.cursor.close().then(undefined, squashError);
954
953
 
955
954
  const topology = getTopology(this.parent);
@@ -957,7 +956,7 @@ export class ChangeStream<
957
956
  .selectServer(this.cursor.readPreference, {
958
957
  operationName: 'reconnect topology in change stream'
959
958
  })
960
- // eslint-disable-next-line github/no-then
959
+
961
960
  .then(
962
961
  () => {
963
962
  this.cursor = this._createChangeStreamCursor(this.cursor.resumeOptions);
@@ -49,7 +49,7 @@ export class MongocryptdManager {
49
49
  async spawn(): Promise<void> {
50
50
  const cmdName = this.spawnPath || 'mongocryptd';
51
51
 
52
- // eslint-disable-next-line @typescript-eslint/no-var-requires
52
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
53
53
  const { spawn } = require('child_process') as typeof import('child_process');
54
54
 
55
55
  // Spawned with stdio: ignore and detached: true
@@ -168,7 +168,7 @@ export async function performGSSAPICanonicalizeHostName(
168
168
  const results = await dns.promises.resolvePtr(address);
169
169
  // If the ptr did not error but had no results, return the host.
170
170
  return results.length > 0 ? results[0] : host;
171
- } catch (error) {
171
+ } catch {
172
172
  // This can error as ptr records may not exist for all ips. In this case
173
173
  // fallback to a cname lookup as dns.lookup() does not return the
174
174
  // cname.
@@ -78,8 +78,8 @@ export class MongoDBAWS extends AuthProvider {
78
78
  accessKeyId && secretAccessKey && sessionToken
79
79
  ? { accessKeyId, secretAccessKey, sessionToken }
80
80
  : accessKeyId && secretAccessKey
81
- ? { accessKeyId, secretAccessKey }
82
- : undefined;
81
+ ? { accessKeyId, secretAccessKey }
82
+ : undefined;
83
83
 
84
84
  const db = credentials.source;
85
85
  const nonce = await randomBytes(32);
@@ -160,9 +160,9 @@ export abstract class CallbackWorkflow implements Workflow {
160
160
  // previous lock, only the current callback's value would get returned.
161
161
  await lock;
162
162
  lock = lock
163
- // eslint-disable-next-line github/no-then
163
+
164
164
  .catch(() => null)
165
- // eslint-disable-next-line github/no-then
165
+
166
166
  .then(async () => {
167
167
  const difference = Date.now() - this.lastExecutionTime;
168
168
  if (difference <= THROTTLE_MS) {
@@ -115,9 +115,9 @@ export abstract class MachineWorkflow implements Workflow {
115
115
  // previous lock, only the current callback's value would get returned.
116
116
  await lock;
117
117
  lock = lock
118
- // eslint-disable-next-line github/no-then
118
+
119
119
  .catch(() => null)
120
- // eslint-disable-next-line github/no-then
120
+
121
121
  .then(async () => {
122
122
  const difference = Date.now() - this.lastExecutionTime;
123
123
  if (difference <= THROTTLE_MS) {
@@ -75,7 +75,11 @@ export class OpQueryRequest {
75
75
  exhaust: boolean;
76
76
  partial: boolean;
77
77
 
78
- constructor(public databaseName: string, public query: Document, options: OpQueryOptions) {
78
+ constructor(
79
+ public databaseName: string,
80
+ public query: Document,
81
+ options: OpQueryOptions
82
+ ) {
79
83
  // Basic options needed to be passed in
80
84
  // TODO(NODE-3483): Replace with MongoCommandError
81
85
  const ns = `${databaseName}.$cmd`;
@@ -332,7 +332,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
332
332
 
333
333
  this.socket.destroy();
334
334
  this.error = error;
335
- // eslint-disable-next-line github/no-then
335
+
336
336
  this.dataEvents?.throw(error).then(undefined, squashError);
337
337
  this.closed = true;
338
338
  this.emit(Connection.CLOSE);
@@ -602,7 +602,7 @@ export class Connection extends TypedEventEmitter<ConnectionEvents> {
602
602
  }
603
603
  throw new MongoUnexpectedServerResponseError('Server ended moreToCome unexpectedly');
604
604
  };
605
- // eslint-disable-next-line github/no-then
605
+
606
606
  exhaustLoop().then(undefined, replyListener);
607
607
  }
608
608
 
@@ -638,7 +638,6 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
638
638
  new ConnectionCreatedEvent(this, { id: connectOptions.id })
639
639
  );
640
640
 
641
- // eslint-disable-next-line github/no-then
642
641
  connect(connectOptions).then(
643
642
  connection => {
644
643
  // The pool might have closed since we started trying to create a connection
@@ -6,7 +6,7 @@ import { MongoInvalidArgumentError } from '../../error';
6
6
  import type { MongoOptions } from '../../mongo_client';
7
7
  import { fileIsAccessible } from '../../utils';
8
8
 
9
- // eslint-disable-next-line @typescript-eslint/no-var-requires
9
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
10
10
  const NODE_DRIVER_VERSION = require('../../../package.json').version;
11
11
 
12
12
  /**
@@ -1,6 +1,5 @@
1
1
  import { MongoInvalidArgumentError } from '../../error';
2
- import type { ReadPreferenceLike } from '../../read_preference';
3
- import { ReadPreference } from '../../read_preference';
2
+ import { ReadPreference, type ReadPreferenceLike } from '../../read_preference';
4
3
  import { ServerType } from '../../sdam/common';
5
4
  import type { Server } from '../../sdam/server';
6
5
  import type { ServerDescription } from '../../sdam/server_description';
package/src/collection.ts CHANGED
@@ -47,17 +47,18 @@ import {
47
47
  FindOneAndUpdateOperation,
48
48
  type FindOneAndUpdateOptions
49
49
  } from './operations/find_and_modify';
50
- import type {
51
- CreateIndexesOptions,
52
- DropIndexesOptions,
53
- IndexDescription,
54
- IndexDescriptionCompact,
55
- IndexDescriptionInfo,
56
- IndexInformationOptions,
57
- IndexSpecification,
58
- ListIndexesOptions
50
+ import {
51
+ CreateIndexesOperation,
52
+ type CreateIndexesOptions,
53
+ type DropIndexesOptions,
54
+ DropIndexOperation,
55
+ type IndexDescription,
56
+ type IndexDescriptionCompact,
57
+ type IndexDescriptionInfo,
58
+ type IndexInformationOptions,
59
+ type IndexSpecification,
60
+ type ListIndexesOptions
59
61
  } from './operations/indexes';
60
- import { CreateIndexesOperation, DropIndexOperation } from './operations/indexes';
61
62
  import {
62
63
  InsertManyOperation,
63
64
  type InsertManyResult,
@@ -1121,8 +1122,8 @@ export class Collection<TSchema extends Document = Document> {
1121
1122
  indexNameOrOptions == null
1122
1123
  ? null
1123
1124
  : typeof indexNameOrOptions === 'object'
1124
- ? null
1125
- : indexNameOrOptions;
1125
+ ? null
1126
+ : indexNameOrOptions;
1126
1127
 
1127
1128
  return new ListSearchIndexesCursor(this as TODO_NODE_3286, indexName, options);
1128
1129
  }
@@ -73,7 +73,7 @@ export async function resolveSRVRecord(options: MongoOptions): Promise<HostAddre
73
73
  // the SRV record is resolved before starting a second DNS query.
74
74
  const lookupAddress = options.srvHost;
75
75
  const txtResolutionPromise = dns.promises.resolveTxt(lookupAddress);
76
- // eslint-disable-next-line github/no-then
76
+
77
77
  txtResolutionPromise.then(undefined, squashError); // rejections will be handled later
78
78
 
79
79
  // Resolve the SRV record and use the result as the list of hosts to connect to.
@@ -552,7 +552,6 @@ export function parseOptions(
552
552
 
553
553
  mongoOptions.metadata = makeClientMetadata(mongoOptions);
554
554
 
555
- // eslint-disable-next-line github/no-then
556
555
  mongoOptions.extendedMetadata = addContainerMetadata(mongoOptions.metadata).then(
557
556
  undefined,
558
557
  squashError
package/src/constants.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
1
2
  export const SYSTEM_NAMESPACE_COLLECTION = 'system.namespaces';
2
3
  export const SYSTEM_INDEX_COLLECTION = 'system.indexes';
3
4
  export const SYSTEM_PROFILE_COLLECTION = 'system.profile';
@@ -656,7 +656,6 @@ export abstract class AbstractCursor<
656
656
  // We only want to end this session if we created it, and it hasn't ended yet
657
657
  if (session.explicit === false) {
658
658
  if (!session.hasEnded) {
659
- // eslint-disable-next-line github/no-then
660
659
  session.endSession().then(undefined, squashError);
661
660
  }
662
661
  this.cursorSession = this.cursorClient.startSession({ owner: this, explicit: false });
@@ -882,7 +881,6 @@ class ReadableCursorStream extends Readable {
882
881
  }
883
882
 
884
883
  override _destroy(error: Error | null, callback: (error?: Error | null) => void): void {
885
- // eslint-disable-next-line github/no-then
886
884
  this._cursor.close().then(
887
885
  () => callback(error),
888
886
  closeError => callback(closeError)
@@ -895,13 +893,11 @@ class ReadableCursorStream extends Readable {
895
893
  return;
896
894
  }
897
895
 
898
- // eslint-disable-next-line github/no-then
899
896
  this._cursor.next().then(
900
897
  result => {
901
898
  if (result == null) {
902
899
  this.push(null);
903
900
  } else if (this.destroyed) {
904
- // eslint-disable-next-line github/no-then
905
901
  this._cursor.close().then(undefined, squashError);
906
902
  } else {
907
903
  if (this.push(result)) {
@@ -917,7 +913,6 @@ class ReadableCursorStream extends Readable {
917
913
  // a client during iteration. Alternatively, we could do the "right" thing and
918
914
  // propagate the error message by removing this special case.
919
915
  if (err.message.match(/server is closed/)) {
920
- // eslint-disable-next-line github/no-then
921
916
  this._cursor.close().then(undefined, squashError);
922
917
  return this.push(null);
923
918
  }
@@ -5,10 +5,12 @@ import { AggregateOperation, type AggregateOptions } from '../operations/aggrega
5
5
  import { executeOperation } from '../operations/execute_operation';
6
6
  import type { ClientSession } from '../sessions';
7
7
  import type { Sort } from '../sort';
8
- import type { MongoDBNamespace } from '../utils';
9
- import { mergeOptions } from '../utils';
10
- import type { AbstractCursorOptions, InitialCursorResponse } from './abstract_cursor';
11
- import { AbstractCursor } from './abstract_cursor';
8
+ import { mergeOptions, type MongoDBNamespace } from '../utils';
9
+ import {
10
+ AbstractCursor,
11
+ type AbstractCursorOptions,
12
+ type InitialCursorResponse
13
+ } from './abstract_cursor';
12
14
 
13
15
  /** @public */
14
16
  export interface AggregationCursorOptions extends AbstractCursorOptions, AggregateOptions {}
package/src/deps.ts CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
1
  import { type Stream } from './cmap/connect';
3
2
  import { MongoMissingDependencyError } from './error';
4
3
  import type { Callback } from './utils';
@@ -24,6 +23,7 @@ export function getKerberos(): Kerberos {
24
23
  let kerberos: Kerberos;
25
24
  try {
26
25
  // Ensure you always wrap an optional require in the try block NODE-3199
26
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
27
27
  kerberos = require('kerberos');
28
28
  } catch (error) {
29
29
  kerberos = makeErrorModule(
@@ -63,6 +63,7 @@ export type ZStandard = ZStandardLib | { kModuleError: MongoMissingDependencyErr
63
63
  export function getZstdLibrary(): ZStandardLib | { kModuleError: MongoMissingDependencyError } {
64
64
  let ZStandard: ZStandardLib | { kModuleError: MongoMissingDependencyError };
65
65
  try {
66
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
66
67
  ZStandard = require('@mongodb-js/zstd');
67
68
  } catch (error) {
68
69
  ZStandard = makeErrorModule(
@@ -101,6 +102,7 @@ export function getAwsCredentialProvider():
101
102
  | { kModuleError: MongoMissingDependencyError } {
102
103
  try {
103
104
  // Ensure you always wrap an optional require in the try block NODE-3199
105
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
104
106
  const credentialProvider = require('@aws-sdk/credential-providers');
105
107
  return credentialProvider;
106
108
  } catch (error) {
@@ -122,6 +124,7 @@ export type GcpMetadata =
122
124
  export function getGcpMetadata(): GcpMetadata {
123
125
  try {
124
126
  // Ensure you always wrap an optional require in the try block NODE-3199
127
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
125
128
  const credentialProvider = require('gcp-metadata');
126
129
  return credentialProvider;
127
130
  } catch (error) {
@@ -153,6 +156,7 @@ export type SnappyLib = {
153
156
  export function getSnappy(): SnappyLib | { kModuleError: MongoMissingDependencyError } {
154
157
  try {
155
158
  // Ensure you always wrap an optional require in the try block NODE-3199
159
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
156
160
  const value = require('snappy');
157
161
  return value;
158
162
  } catch (error) {
@@ -187,6 +191,7 @@ export type SocksLib = {
187
191
  export function getSocks(): SocksLib | { kModuleError: MongoMissingDependencyError } {
188
192
  try {
189
193
  // Ensure you always wrap an optional require in the try block NODE-3199
194
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
190
195
  const value = require('socks');
191
196
  return value;
192
197
  } catch (error) {
@@ -244,6 +249,7 @@ export const aws4: AWS4 | { kModuleError: MongoMissingDependencyError } = loadAw
244
249
  function loadAws4() {
245
250
  let aws4: AWS4 | { kModuleError: MongoMissingDependencyError };
246
251
  try {
252
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
247
253
  aws4 = require('aws4');
248
254
  } catch (error) {
249
255
  aws4 = makeErrorModule(
@@ -267,6 +273,7 @@ export function getMongoDBClientEncryption():
267
273
  // NOTE(NODE-3199): Ensure you always wrap an optional require literally in the try block
268
274
  // Cannot be moved to helper utility function, bundlers search and replace the actual require call
269
275
  // in a way that makes this line throw at bundle time, not runtime, catching here will make bundling succeed
276
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
270
277
  mongodbClientEncryption = require('mongodb-client-encryption');
271
278
  } catch (error) {
272
279
  const kModuleError = new MongoMissingDependencyError(
package/src/error.ts CHANGED
@@ -1255,9 +1255,8 @@ export function needsRetryableWriteLabel(
1255
1255
  // use original top-level code from server response
1256
1256
  return RETRYABLE_WRITE_ERROR_CODES.has(error.result.code ?? 0);
1257
1257
  }
1258
- return RETRYABLE_WRITE_ERROR_CODES.has(
1259
- error.result.writeConcernError.code ?? Number(error.code) ?? 0
1260
- );
1258
+ const code = error.result.writeConcernError.code ?? Number(error.code);
1259
+ return RETRYABLE_WRITE_ERROR_CODES.has(Number.isNaN(code) ? 0 : code);
1261
1260
  }
1262
1261
 
1263
1262
  if (error instanceof MongoError) {
@@ -216,7 +216,7 @@ function doRead(stream: GridFSBucketReadStream): void {
216
216
 
217
217
  if (!doc) {
218
218
  stream.push(null);
219
- // eslint-disable-next-line github/no-then
219
+
220
220
  stream.s.cursor?.close().then(undefined, error => stream.destroy(error));
221
221
  return;
222
222
  }
@@ -288,7 +288,6 @@ function doRead(stream: GridFSBucketReadStream): void {
288
288
  return;
289
289
  };
290
290
 
291
- // eslint-disable-next-line github/no-then
292
291
  stream.s.cursor.next().then(handleReadResult, error => {
293
292
  if (stream.destroyed) return;
294
293
  stream.destroy(error);
@@ -372,7 +371,6 @@ function init(stream: GridFSBucketReadStream): void {
372
371
  return;
373
372
  };
374
373
 
375
- // eslint-disable-next-line github/no-then
376
374
  stream.s.files.findOne(stream.s.filter, findOneOptions).then(handleReadResult, error => {
377
375
  if (stream.destroyed) return;
378
376
  stream.destroy(error);
@@ -1,7 +1,6 @@
1
1
  import { Writable } from 'stream';
2
2
 
3
- import type { Document } from '../bson';
4
- import { ObjectId } from '../bson';
3
+ import { type Document, ObjectId } from '../bson';
5
4
  import type { Collection } from '../collection';
6
5
  import { MongoAPIError, MONGODB_ERROR_CODES, MongoError } from '../error';
7
6
  import { type Callback, squashError } from '../utils';
@@ -135,7 +134,6 @@ export class GridFSBucketWriteStream extends Writable {
135
134
  if (!this.bucket.s.calledOpenUploadStream) {
136
135
  this.bucket.s.calledOpenUploadStream = true;
137
136
 
138
- // eslint-disable-next-line github/no-then
139
137
  checkIndexes(this).then(() => {
140
138
  this.bucket.s.checkedIndexes = true;
141
139
  this.bucket.emit('index');
@@ -272,7 +270,6 @@ function checkDone(stream: GridFSBucketWriteStream, callback: Callback): void {
272
270
  return;
273
271
  }
274
272
 
275
- // eslint-disable-next-line github/no-then
276
273
  stream.files.insertOne(gridFSFile, { writeConcern: stream.writeConcern }).then(
277
274
  () => {
278
275
  stream.gridFSFile = gridFSFile;
@@ -396,7 +393,6 @@ function doWrite(
396
393
  return;
397
394
  }
398
395
 
399
- // eslint-disable-next-line github/no-then
400
396
  stream.chunks.insertOne(doc, { writeConcern: stream.writeConcern }).then(
401
397
  () => {
402
398
  --stream.state.outstandingRequests;
@@ -437,7 +433,6 @@ function writeRemnant(stream: GridFSBucketWriteStream, callback: Callback): void
437
433
  return;
438
434
  }
439
435
 
440
- // eslint-disable-next-line github/no-then
441
436
  stream.chunks.insertOne(doc, { writeConcern: stream.writeConcern }).then(
442
437
  () => {
443
438
  --stream.state.outstandingRequests;
@@ -839,9 +839,9 @@ export class MongoLogger {
839
839
 
840
840
  if (isPromiseLike(this.pendingLog)) {
841
841
  this.pendingLog = this.pendingLog
842
- // eslint-disable-next-line github/no-then
842
+
843
843
  .then(() => this.logDestination.write(logMessage))
844
- // eslint-disable-next-line github/no-then
844
+
845
845
  .then(this.clearPendingLog.bind(this), this.logWriteFailureHandler.bind(this));
846
846
  return;
847
847
  }
@@ -849,7 +849,6 @@ export class MongoLogger {
849
849
  try {
850
850
  const logResult = this.logDestination.write(logMessage);
851
851
  if (isPromiseLike(logResult)) {
852
- // eslint-disable-next-line github/no-then
853
852
  this.pendingLog = logResult.then(
854
853
  this.clearPendingLog.bind(this),
855
854
  this.logWriteFailureHandler.bind(this)