Skip to content

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

Merged
merged 9 commits into from
Apr 28, 2025

Conversation

vkarpov15
Copy link
Collaborator

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

@vkarpov15 vkarpov15 added this to the 9.0 milestone Apr 28, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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

Copy link
Collaborator

@hasezoey hasezoey left a 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?

@vkarpov15 vkarpov15 merged commit 98b4f0f into 9.0 Apr 28, 2025
51 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/async-custom-hooks-statics branch April 28, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants