kareem icon indicating copy to clipboard operation
kareem copied to clipboard

BREAKING CHANGE: make execPre async and drop callback support

Open vkarpov15 opened this issue 7 months ago • 0 comments

Work in progress to make execPre() and execPost() use async functions where possible to better support https://github.com/Automattic/mongoose/issues/15317. Tested in kareem repo as well as running Mongoose with these changes.

Couple of breaking changes in this PR:

  1. No longer support passing arguments to the next middleware. Previously, you could do next(null, 'new arg') and the args to the next middleware would get overwritten by 'new arg'.
  2. No more callback support for execPre()
  3. Errors take precedence over next() calls. If your middleware function does something like next(); throw new Error('Fail');, this new logic will treat the middleware function as errored with error 'Fail'. Kareem@2 ignores the 'Fail' error.

@hasezoey your feedback would be much appreciated.

vkarpov15 avatar Mar 19 '25 21:03 vkarpov15