diff --git a/package-lock.json b/package-lock.json index 28ccaa00b6..e5f6e79dab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43897,7 +43897,8 @@ "diff-match-patch": "overleaf/diff-match-patch#89805f9c671a77a263fc53461acd62aa7498f688", "express": "^4.18.2", "lodash": "^4.17.21", - "mongodb": "^4.11.0", + "mongodb": "^6.2.0", + "mongodb-legacy": "^6.0.1", "request": "^2.88.2", "requestretry": "^7.1.0" }, @@ -43913,54 +43914,70 @@ } }, "services/document-updater/node_modules/bson": { - "version": "4.7.2", - "resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz", - "integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==", - "dependencies": { - "buffer": "^5.6.0" - }, + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", + "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", "engines": { - "node": ">=6.9.0" + "node": ">=16.20.1" } }, - "services/document-updater/node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], + "services/document-updater/node_modules/gcp-metadata": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", + "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", + "optional": true, + "peer": true, "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" + "gaxios": "^5.0.0", + "json-bigint": "^1.0.0" + }, + "engines": { + "node": ">=12" } }, "services/document-updater/node_modules/mongodb": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz", - "integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.2.0.tgz", + "integrity": "sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==", "dependencies": { - "bson": "^4.7.2", - "mongodb-connection-string-url": "^2.6.0", - "socks": "^2.7.1" + "@mongodb-js/saslprep": "^1.1.0", + "bson": "^6.2.0", + "mongodb-connection-string-url": "^2.6.0" }, "engines": { - "node": ">=12.9.0" + "node": ">=16.20.1" }, - "optionalDependencies": { - "@aws-sdk/credential-providers": "^3.186.0", - "@mongodb-js/saslprep": "^1.1.0" + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.188.0", + "@mongodb-js/zstd": "^1.1.0", + "gcp-metadata": "^5.2.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=6.0.0 <7", + "snappy": "^7.2.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 + } } }, "services/filestore": { @@ -54189,7 +54206,8 @@ "express": "^4.18.2", "lodash": "^4.17.21", "mocha": "^10.2.0", - "mongodb": "^4.11.0", + "mongodb": "^6.2.0", + "mongodb-legacy": "^6.0.1", "request": "^2.88.2", "requestretry": "^7.1.0", "sandboxed-module": "^2.0.4", @@ -54199,32 +54217,29 @@ }, "dependencies": { "bson": { - "version": "4.7.2", - "resolved": "https://registry.npmjs.org/bson/-/bson-4.7.2.tgz", - "integrity": "sha512-Ry9wCtIZ5kGqkJoi6aD8KjxFZEx78guTQDnpXWiNthsxzrxAK/i8E6pCHAIZTbaEFWcOCvbecMukfK7XUvyLpQ==", - "requires": { - "buffer": "^5.6.0" - } + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", + "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==" }, - "buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "gcp-metadata": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-5.3.0.tgz", + "integrity": "sha512-FNTkdNEnBdlqF2oatizolQqNANMrcqJt6AAYt99B3y1aLLC8Hc5IOBb+ZnnzllodEEf6xMBp6wRcBbc16fa65w==", + "optional": true, + "peer": true, "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" + "gaxios": "^5.0.0", + "json-bigint": "^1.0.0" } }, "mongodb": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-4.17.1.tgz", - "integrity": "sha512-MBuyYiPUPRTqfH2dV0ya4dcr2E5N52ocBuZ8Sgg/M030nGF78v855B3Z27mZJnp8PxjnUquEnAtjOsphgMZOlQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.2.0.tgz", + "integrity": "sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==", "requires": { - "@aws-sdk/credential-providers": "^3.186.0", "@mongodb-js/saslprep": "^1.1.0", - "bson": "^4.7.2", - "mongodb-connection-string-url": "^2.6.0", - "socks": "^2.7.1" + "bson": "^6.2.0", + "mongodb-connection-string-url": "^2.6.0" } } } diff --git a/services/document-updater/app/js/SnapshotManager.js b/services/document-updater/app/js/SnapshotManager.js index 78084e024c..194e043549 100644 --- a/services/document-updater/app/js/SnapshotManager.js +++ b/services/document-updater/app/js/SnapshotManager.js @@ -16,8 +16,8 @@ const { db, ObjectId } = require('./mongodb') module.exports = SnapshotManager = { recordSnapshot(projectId, docId, version, pathname, lines, ranges, callback) { try { - projectId = ObjectId(projectId) - docId = ObjectId(docId) + projectId = new ObjectId(projectId) + docId = new ObjectId(docId) } catch (error) { return callback(error) } @@ -70,7 +70,7 @@ module.exports = SnapshotManager = { _safeObjectId(data) { try { - return ObjectId(data) + return new ObjectId(data) } catch (error) { return data } diff --git a/services/document-updater/app/js/mongodb.js b/services/document-updater/app/js/mongodb.js index 52868d45c8..8d5258e1d9 100644 --- a/services/document-updater/app/js/mongodb.js +++ b/services/document-updater/app/js/mongodb.js @@ -1,6 +1,6 @@ const Metrics = require('@overleaf/metrics') const Settings = require('@overleaf/settings') -const { MongoClient, ObjectId } = require('mongodb') +const { MongoClient, ObjectId } = require('mongodb-legacy') const mongoClient = new MongoClient(Settings.mongo.url) const mongoDb = mongoClient.db() diff --git a/services/document-updater/package.json b/services/document-updater/package.json index f1c86b2897..56821adb8f 100644 --- a/services/document-updater/package.json +++ b/services/document-updater/package.json @@ -29,7 +29,8 @@ "diff-match-patch": "overleaf/diff-match-patch#89805f9c671a77a263fc53461acd62aa7498f688", "express": "^4.18.2", "lodash": "^4.17.21", - "mongodb": "^4.11.0", + "mongodb": "^6.2.0", + "mongodb-legacy": "^6.0.1", "request": "^2.88.2", "requestretry": "^7.1.0" }, diff --git a/services/document-updater/scripts/remove_deleted_docs.js b/services/document-updater/scripts/remove_deleted_docs.js index 78965ac31b..c614c354d7 100644 --- a/services/document-updater/scripts/remove_deleted_docs.js +++ b/services/document-updater/scripts/remove_deleted_docs.js @@ -19,7 +19,7 @@ async function removeDeletedDocs(dockeys, options) { const docIds = ProjectFlusher._extractIds(dockeys) for (const docId of docIds) { summary.totalDocs++ - const docCount = await db.docs.find({ _id: ObjectId(docId) }).count() + const docCount = await db.docs.find({ _id: new ObjectId(docId) }).count() if (!docCount) { try { await removeDeletedDoc(docId, options) @@ -44,7 +44,7 @@ async function removeDeletedDoc(docId, options) { lastUpdatedBy, ] = await getDoc(projectId, docId) - const project = await db.projects.findOne({ _id: ObjectId(projectId) }) + const project = await db.projects.findOne({ _id: new ObjectId(projectId) }) let status diff --git a/services/document-updater/test/acceptance/js/RangesTests.js b/services/document-updater/test/acceptance/js/RangesTests.js index 809e8e4b62..102205709c 100644 --- a/services/document-updater/test/acceptance/js/RangesTests.js +++ b/services/document-updater/test/acceptance/js/RangesTests.js @@ -703,8 +703,8 @@ describe('Ranges', function () { } db.docSnapshots .find({ - project_id: ObjectId(this.project_id), - doc_id: ObjectId(this.doc_id), + project_id: new ObjectId(this.project_id), + doc_id: new ObjectId(this.doc_id), }) .toArray((error, docSnapshots) => { if (error != null) {