Skip to content
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

pre 'save' without a callback function fails with unhelpful error message #8087

Closed
ameyanekar opened this issue Aug 20, 2019 · 1 comment
Closed
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Milestone

Comments

@ameyanekar
Copy link

Do you want to request a feature or report a bug?
bug

What is the current behavior?
Throws an error from the kareem library. Error does not refer to the pre save line of code.

If the current behavior is a bug, please provide the steps to reproduce.

  1. Register a pre save hook without any callback: userSchema.pre('save');
  2. Execute model.save();

What is the expected behavior?
Error message should be descriptive providing the line of code of the pre save line

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node v10.16.0
mongoose@5.6.9
MongoDB v3.4.18

Complete Error Message Below:

/xxx/xxx/xxx/api-server/node_modules/kareem/index.js:51
    } else if (pre.fn.length > 0) {
                      ^

TypeError: Cannot read property 'length' of undefined
    at model.next (/xxx/api-server/node_modules/kareem/index.js:51:23)
    at _next (/xxx/api-server/node_modules/kareem/index.js:106:10)
    at process.nextTick (/xxx/api-server/node_modules/kareem/index.js:499:38)
    at process._tickCallback (internal/process/next_tick.js:61:11)
@ameyanekar ameyanekar changed the title pre 'save' without a callback function fails with cryptic error message pre 'save' without a callback function fails with unhelpful error message Aug 20, 2019
@vkarpov15 vkarpov15 added this to the 5.6.11 milestone Aug 21, 2019
@vkarpov15 vkarpov15 added the enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature label Aug 21, 2019
vkarpov15 added a commit to mongoosejs/kareem that referenced this issue Aug 22, 2019
@ameyanekar
Copy link
Author

Thank you for the swift action @vkarpov15

vkarpov15 added a commit that referenced this issue Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
Projects
None yet
Development

No branches or pull requests

2 participants