Mongoose Schema.pre insertMany middleware
It is because you provide wrong arguments in callback. Hook apply only 'next' argument. You need change your callback function arguments from (err, docs, next) to (next, docs) and it should work for you.
Details you can see herehttps://mongoosejs.com/docs/middleware.html#pre
https://mongoosejs.com/docs/middleware.html#types-of-middleware