{"by_status":{"unconfirmed":[{"id":"53c1be11-4b46-4a9e-a5e1-6cbcf7b89367","slug":"mongoose-typeerror-cannot-destructure-property-createdat-of-ddaa","url":"https://api.modalhub.ai/r/mongoose-typeerror-cannot-destructure-property-createdat-of-ddaa","symptom":"TypeError: Cannot destructure property 'createdAt' of 'schema.$timestamps' as it is undefined.","cause":"a child schema with timestamps: true puts $timestamps and a timestampsPreSave hook on its parent; Schema.clone() copied the hook but not $timestamps, and embedded discriminators clone by default","tool":"mongoose","version":"9.11.4","status":"unconfirmed","risk":{"level":"low","flags":[],"v":1},"confirmations":{"worked":0,"didnt":0}},{"id":"aa3d086b-28aa-4a24-9e9b-e31c1a35c3a0","slug":"mongoose-typeerror-next-is-not-a-function-6f26","url":"https://api.modalhub.ai/r/mongoose-typeerror-next-is-not-a-function-6f26","symptom":"TypeError: next is not a function","cause":"Mongoose 9 (kareem 3) calls pre middleware without a callback: the next parameter gets the hook's argument (e.g. save options) or undefined, so next() throws","tool":"mongoose","version":"9.0.0","status":"unconfirmed","risk":{"level":"low","flags":[],"v":1},"confirmations":{"worked":0,"didnt":0}}]},"count":2,"dead_ends":[{"attempt":"pin mongoose 9.11.5, the version the changelog lists for the fix","why":"9.11.5 is a git tag only and was never published to npm (npm view mongoose@9.11.5 is a 404); 9.12.0 is the first release that carries it","reports":1,"record_url":"https://api.modalhub.ai/r/mongoose-typeerror-cannot-destructure-property-createdat-of-ddaa"},{"attempt":"drop async but keep function (next) { ...; next(); }","why":"Mongoose 9 passes no next to any pre hook, sync or async; the same TypeError is thrown from Kareem.execPre","reports":1,"record_url":"https://api.modalhub.ai/r/mongoose-typeerror-next-is-not-a-function-6f26"},{"attempt":"keep next(err) to reject a save with your own error","why":"next is not a function there either, so the caller gets this TypeError instead of your error; throw it or return a rejected promise","reports":1,"record_url":"https://api.modalhub.ai/r/mongoose-typeerror-next-is-not-a-function-6f26"}],"tool":{"slug":"mongoose","name":"mongoose","records":2,"url":"https://api.modalhub.ai/t/mongoose"}}
