diff --git a/server/routerlicious/packages/services/package.json b/server/routerlicious/packages/services/package.json index 814ed947f03a..b07722f60d49 100644 --- a/server/routerlicious/packages/services/package.json +++ b/server/routerlicious/packages/services/package.json @@ -67,7 +67,7 @@ "ioredis": "^5.6.1", "lodash": "^4.18.1", "lru-cache": "^6.0.0", - "mongodb": "^5.9.2", + "mongodb": "^6.21.0", "nconf": "^0.12.0", "socket.io": "^4.8.3", "telegrafjs": "^0.1.3", diff --git a/server/routerlicious/packages/services/src/mongodb.ts b/server/routerlicious/packages/services/src/mongodb.ts index b5b7f8d9e4c6..c78729b4cec0 100644 --- a/server/routerlicious/packages/services/src/mongodb.ts +++ b/server/routerlicious/packages/services/src/mongodb.ts @@ -304,7 +304,7 @@ export class MongoCollection implements core.ICollection, query: any, value: any, options = { - returnOriginal: true, + returnDocument: "before" as const, upsert: true, }, ): Promise<{ value: T; existing: boolean }> { @@ -316,8 +316,8 @@ export class MongoCollection implements core.ICollection, options, ); - return result.value - ? { value: result.value, existing: true } + return result + ? { value: result as unknown as T, existing: true } : { value, existing: false }; } catch (sdkError) { const error = this.cloneError(sdkError); @@ -345,8 +345,8 @@ export class MongoCollection implements core.ICollection, options, ); - return result.value - ? { value: result.value, existing: true } + return result + ? { value: result as unknown as T, existing: true } : { value, existing: false }; } catch (sdkError) { const error = this.cloneError(sdkError); @@ -629,7 +629,6 @@ const DefaultMongoDbMonitoringEvents = [ "connectionPoolCleared", ]; const DefaultHeartbeatFrequencyMS = 30000; -const DefaultKeepAliveInitialDelay = 60000; const DefaultSocketTimeoutMS = 0; const DefaultConnectionTimeoutMS = 120000; const DefaultMinHeartbeatFrequencyMS = 10000; @@ -656,7 +655,6 @@ interface IMongoDBConfig { connectionNotAvailableMode?: ConnectionNotAvailableMode; dbMonitoringEventsList?: string[]; heartbeatFrequencyMS?: number; - keepAliveInitialDelay?: number; socketTimeoutMS?: number; connectionTimeoutMS?: number; minHeartbeatFrequencyMS?: number; @@ -682,7 +680,6 @@ export class MongoDbFactory implements core.IDbFactory { private readonly retryRuleOverride: Map; private readonly dbMonitoringEventsList: string[]; private readonly heartbeatFrequencyMS: number; - private readonly keepAliveInitialDelay: number; private readonly socketTimeoutMS: number; private readonly connectionTimeoutMS: number; private readonly minHeartbeatFrequencyMS: number; @@ -706,7 +703,6 @@ export class MongoDbFactory implements core.IDbFactory { connectionNotAvailableMode, dbMonitoringEventsList, heartbeatFrequencyMS, - keepAliveInitialDelay, socketTimeoutMS, connectionTimeoutMS, minHeartbeatFrequencyMS, @@ -738,7 +734,6 @@ export class MongoDbFactory implements core.IDbFactory { : new Map(); this.dbMonitoringEventsList = dbMonitoringEventsList ?? DefaultMongoDbMonitoringEvents; this.heartbeatFrequencyMS = heartbeatFrequencyMS ?? DefaultHeartbeatFrequencyMS; - this.keepAliveInitialDelay = keepAliveInitialDelay ?? DefaultKeepAliveInitialDelay; this.socketTimeoutMS = socketTimeoutMS ?? DefaultSocketTimeoutMS; this.connectionTimeoutMS = connectionTimeoutMS ?? DefaultConnectionTimeoutMS; this.minHeartbeatFrequencyMS = minHeartbeatFrequencyMS ?? DefaultMinHeartbeatFrequencyMS; @@ -762,8 +757,6 @@ export class MongoDbFactory implements core.IDbFactory { // Need to cast to any before MongoClientOptions due to missing properties in d.ts const options: MongoClientOptions = { directConnection: this.directConnection ?? false, - keepAlive: true, - keepAliveInitialDelay: this.keepAliveInitialDelay, socketTimeoutMS: this.socketTimeoutMS, connectTimeoutMS: this.connectionTimeoutMS, heartbeatFrequencyMS: this.heartbeatFrequencyMS, diff --git a/server/routerlicious/pnpm-lock.yaml b/server/routerlicious/pnpm-lock.yaml index 2046f77b56df..78b615be67d8 100644 --- a/server/routerlicious/pnpm-lock.yaml +++ b/server/routerlicious/pnpm-lock.yaml @@ -1069,8 +1069,8 @@ importers: specifier: ^6.0.0 version: 6.0.0 mongodb: - specifier: ^5.9.2 - version: 5.9.2 + specifier: ^6.21.0 + version: 6.21.0(socks@2.8.3) nconf: specifier: ^0.12.0 version: 0.12.1 @@ -2916,6 +2916,9 @@ packages: '@mongodb-js/saslprep@1.1.1': resolution: {integrity: sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==} + '@mongodb-js/saslprep@1.4.11': + resolution: {integrity: sha512-o9rAHc0IpIjuPSxRutWpE1F62x7n+4mVS4rCNHkzhIUMQcc18bb6xEq5wd2NdN0WjepIyXIppRshYI2kQDOZVA==} + '@napi-rs/wasm-runtime@0.2.12': resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==} @@ -3430,6 +3433,9 @@ packages: '@types/webidl-conversions@7.0.3': resolution: {integrity: sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==} + '@types/whatwg-url@11.0.5': + resolution: {integrity: sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==} + '@types/whatwg-url@8.2.2': resolution: {integrity: sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==} @@ -4103,9 +4109,9 @@ packages: resolution: {integrity: sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==} engines: {node: '>=6.9.0'} - bson@5.5.1: - resolution: {integrity: sha512-ix0EwukN2EpC0SRWIj/7B5+A6uQMQy6KMREI9qQqvgpkV2frH63T0UDVd1SYedL6dNCmDBYB3QtXi4ISk9YT+g==} - engines: {node: '>=14.20.1'} + bson@6.10.4: + resolution: {integrity: sha512-WIsKqkSC0ABoBJuT1LEX+2HEvNmNKKgnTAyd0fL8qzK4SH2i9NXg+t08YtdZp/V9IZ33cxe3iV4yM0qg8lMQng==} + engines: {node: '>=16.20.1'} buffer-alloc-unsafe@1.1.0: resolution: {integrity: sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==} @@ -6663,30 +6669,39 @@ packages: mongodb-connection-string-url@2.6.0: resolution: {integrity: sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ==} + mongodb-connection-string-url@3.0.2: + resolution: {integrity: sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==} + mongodb@4.17.1: resolution: {integrity: sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==} engines: {node: '>=12.9.0'} - mongodb@5.9.2: - resolution: {integrity: sha512-H60HecKO4Bc+7dhOv4sJlgvenK4fQNqqUIlXxZYQNbfEWSALGAwGoyJd/0Qwk4TttFXUOHJ2ZJQe/52ScaUwtQ==} - engines: {node: '>=14.20.1'} + mongodb@6.21.0: + resolution: {integrity: sha512-URyb/VXMjJ4da46OeSXg+puO39XH9DeQpWCslifrRn9JWugy0D+DvvBvkm2WxmHe61O/H19JM66p1z7RHVkZ6A==} + engines: {node: '>=16.20.1'} peerDependencies: '@aws-sdk/credential-providers': '*' - '@mongodb-js/zstd': ^1.0.0 - kerberos: ^1.0.0 || ^2.0.0 - mongodb-client-encryption: '>=2.3.0 <3' - snappy: ^7.2.2 + '@mongodb-js/zstd': ^1.1.0 || ^2.0.0 + gcp-metadata: ^5.2.0 + kerberos: ^2.0.1 + mongodb-client-encryption: '>=6.0.0 <7' + snappy: ^7.3.2 + socks: ^2.7.1 peerDependenciesMeta: '@aws-sdk/credential-providers': optional: true '@mongodb-js/zstd': optional: true + gcp-metadata: + optional: true kerberos: optional: true mongodb-client-encryption: optional: true snappy: optional: true + socks: + optional: true morgan@1.10.0: resolution: {integrity: sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==} @@ -8225,6 +8240,10 @@ packages: resolution: {integrity: sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==} engines: {node: '>=12'} + tr46@5.1.1: + resolution: {integrity: sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==} + engines: {node: '>=18'} + traverse@0.3.9: resolution: {integrity: sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==} @@ -8579,6 +8598,10 @@ packages: resolution: {integrity: sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==} engines: {node: '>=12'} + whatwg-url@14.2.0: + resolution: {integrity: sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==} + engines: {node: '>=18'} + whatwg-url@5.0.0: resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} @@ -10187,6 +10210,10 @@ snapshots: sparse-bitfield: 3.0.3 optional: true + '@mongodb-js/saslprep@1.4.11': + dependencies: + sparse-bitfield: 3.0.3 + '@napi-rs/wasm-runtime@0.2.12': dependencies: '@emnapi/core': 1.5.0 @@ -10854,6 +10881,10 @@ snapshots: '@types/webidl-conversions@7.0.3': {} + '@types/whatwg-url@11.0.5': + dependencies: + '@types/webidl-conversions': 7.0.3 + '@types/whatwg-url@8.2.2': dependencies: '@types/node': 22.19.17 @@ -11617,7 +11648,7 @@ snapshots: dependencies: buffer: 5.7.1 - bson@5.5.1: {} + bson@6.10.4: {} buffer-alloc-unsafe@1.1.0: {} @@ -14270,8 +14301,7 @@ snapshots: dependencies: '@octokit/rest': 22.0.1 - memory-pager@1.5.0: - optional: true + memory-pager@1.5.0: {} merge-descriptors@1.0.3: {} @@ -14615,6 +14645,11 @@ snapshots: '@types/whatwg-url': 8.2.2 whatwg-url: 11.0.0 + mongodb-connection-string-url@3.0.2: + dependencies: + '@types/whatwg-url': 11.0.5 + whatwg-url: 14.2.0 + mongodb@4.17.1: dependencies: bson: 4.7.2 @@ -14623,13 +14658,13 @@ snapshots: optionalDependencies: '@mongodb-js/saslprep': 1.1.1 - mongodb@5.9.2: + mongodb@6.21.0(socks@2.8.3): dependencies: - bson: 5.5.1 - mongodb-connection-string-url: 2.6.0 - socks: 2.8.3 + '@mongodb-js/saslprep': 1.4.11 + bson: 6.10.4 + mongodb-connection-string-url: 3.0.2 optionalDependencies: - '@mongodb-js/saslprep': 1.1.1 + socks: 2.8.3 morgan@1.10.0: dependencies: @@ -16172,7 +16207,6 @@ snapshots: sparse-bitfield@3.0.3: dependencies: memory-pager: 1.5.0 - optional: true spawn-please@2.0.2: dependencies: @@ -16507,6 +16541,10 @@ snapshots: dependencies: punycode: 2.3.1 + tr46@5.1.1: + dependencies: + punycode: 2.3.1 + traverse@0.3.9: {} tree-kill@1.2.2: {} @@ -16924,6 +16962,11 @@ snapshots: tr46: 3.0.0 webidl-conversions: 7.0.0 + whatwg-url@14.2.0: + dependencies: + tr46: 5.1.1 + webidl-conversions: 7.0.0 + whatwg-url@5.0.0: dependencies: tr46: 0.0.3