MongooseError: Query was already executed: User.countDocuments({})

Solution 1:

It seems that you are using Mongoose. It seems you are mixing between async-await and callbacks.

Change await User.countDocuments((count) => count) to await User.countDocuments()