OpenUserJS / OpenUserJS.org

The home of FOSS user scripts.
https://openuserjs.org/
GNU General Public License v3.0
857 stars 305 forks source link

MongoDB/*mongoose* deprecations #1516

Open Martii opened 6 years ago

Martii commented 6 years ago
(node:26124) DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead

We use .count in at least [one place] where this can be changed although upstream says it's still using the MongoDB v3.x driver... so that's confusing.

Refs:

With --trace-deprecation:

(node:7904) DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead
    at NativeCollection.(anonymous function) [as count] (~/OpenUserJS.org2/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:146:28)
    at NodeCollection.count (~/OpenUserJS.org2/node_modules/mquery/lib/collection/node.js:50:19)
    at model.Query.Query._count (~/OpenUserJS.org2/node_modules/mongoose/lib/query.js:2081:20)
    at process.nextTick (~/OpenUserJS.org2/node_modules/kareem/index.js:369:33)
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:7904) DeprecationWarning: Cursor.each is deprecated. Use Cursor.forEach instead.
    at ~/OpenUserJS.org2/libs/modifySessions.js:293:19
    at handleCallback (~/OpenUserJS.org2/node_modules/mongodb/lib/utils.js:128:55)
    at Collection.<anonymous> (~/OpenUserJS.org2/node_modules/mongodb/lib/collection.js:432:45)
    at Collection.deprecated [as find] (~/OpenUserJS.org2/node_modules/mongodb/lib/utils.js:661:17)
    at exports.findSessionData (~/OpenUserJS.org2/libs/modifySessions.js:279:15)
    at Timeout.ttlSanity [as _onTimeout] (~/OpenUserJS.org2/app.js:552:3)
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)

... doing this kills session management... so delay.... FIXED (this one code fence only)


(node:10349) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Martii commented 6 years ago

These show up in local pro (different MongoDB version... already emailed sizzle about this incongruity):

(node:26443) DeprecationWarning: collection.find option [fields] is deprecated and will be removed in a later version.
(node:26443) DeprecationWarning: collection.find option [fields] is deprecated and will be removed in a later version.
Connected to MongoDB v3.0.15
GitHub client authenticated
(node:26443) DeprecationWarning: collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.
(node:26443) DeprecationWarning: collection.count is deprecated, and will be removed in a future version. Use collection.countDocuments or collection.estimatedDocumentCount instead
(node:26443) DeprecationWarning: Cursor.each is deprecated. Use Cursor.forEach instead.

And some more...

(node:26443) DeprecationWarning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.
(node:26443) DeprecationWarning: collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.
(node:26443) DeprecationWarning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.

Ref:


(node:32265) DeprecationWarning: collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.

... string findAndModify not found in our project but other deps have it.

...

(node:12406) DeprecationWarning: Mongoose: `findOneAndUpdate()` and `findOneAndDelete()` without the `useFindAndModify` option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#-findandmodify-

Ref: Automattic/mongoose#7865

Martii commented 4 years ago

During a dep update test cycle...

(node:9303) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'createCollection' of undefined
    at NativeConnection.createCollection (~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/connection.js:356:11)
    at ~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/connection.js:451:12
    at Object.promiseOrCallback (~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/utils.js:261:12)
    at NativeConnection.createCollection (~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/connection.js:445:18)
    at ~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/model.js:1299:13
    at Object.promiseOrCallback (~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/utils.js:261:12)
    at Function.createCollection (~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/model.js:1296:16)
    at ~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/model.js:1340:10
    at ~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/utils.js:283:5
    at new Promise (<anonymous>)
    at Object.promiseOrCallback (~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/utils.js:282:10)
    at Function.syncIndexes (~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/node_modules/mongoose/lib/model.js:1337:16)
    at Object.<anonymous> (~/repo/git/OpenUserJS.org/martii/OpenUserJS.org/models/script.js:86:8)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
(node:9303) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9303) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

... as far as I know we don't use promises but deps may internally.

Squashed during testing:

(node:8993) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:9088) DeprecationWarning: The option `reconnectTries` is incompatible with the unified topology, please read more by visiting http://bit.ly/2D8WfT6
(node:9088) DeprecationWarning: The option `reconnectInterval` is incompatible with the unified topology, please read more by visiting http://bit.ly/2D8WfT6