-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
BREAKING CHANGE: Async stack traces for custom methods and statics, remove promiseOrCallback()
#15376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes callback support from custom methods and statics by eliminating the promiseOrCallback helper and updating middleware hook handling. It also improves async stack traces for static hooks and updates corresponding tests and documentation.
- Removed promiseOrCallback helper and its tests.
- Updated custom method/statically hooked functions to return Promises.
- Adjusted test cases and migration documentation, plus updated CI Node.js versions.
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
test/model.middleware.test.js | Added test for async stack traces in static hooks. |
test/helpers/promiseOrCallback.test.js | Removed tests for now-deprecated promiseOrCallback helper. |
test/document.test.js | Updated custom method hooks from callback to async, with new tests. |
lib/utils.js | Removed export of promiseOrCallback. |
lib/helpers/promiseOrCallback.js | Removed deprecated helper file. |
lib/helpers/model/applyStaticHooks.js | Replaced wrapper logic with hooks.createWrapper. |
lib/helpers/model/applyHooks.js | Switched to a wrapper-based approach for custom methods. |
docs/migrating_to_9.md | Documented the breaking change and migration path to async methods. |
.github/workflows/test.yml | Updated supported Node.js versions. |
Files not reviewed (1)
- package.json: Language not supported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Should this PR also make a note in the Changelog about the changed nodejs requirement, or is this for another PR?
Co-authored-by: hasezoey <[email protected]>
…omattic/mongoose into vkarpov15/async-custom-hooks-statics
Summary
Some more changes re: mongoosejs/kareem#39. Given that we've gotten rid of
promiseOrCallback()
, this also means we've finally fully removed callback support from our client-facing API. The last outstanding callback support was for hooks for custom statics and methods.Examples