Skip to content

mongoose-bcrypt plugin incompatible with Mongoose 9 - "next is not a function" #40

@erksdee

Description

@erksdee

Experiencing a runtime error when saving documents that use the mongoose-bcrypt plugin for password hashing. The error occurs in production on AWS Lambda. Error Stack Trace:

{
    "errorType": "TypeError",
    "errorMessage": "next is not a function",
    "stack": [
        "TypeError: next is not a function",
        "    at model.<anonymous> (/var/task/node_modules/mongoose-bcrypt/index.js:115:7)",
        "    at Kareem.execPre (/var/task/node_modules/kareem/index.js:63:39)",
        "    at async model.$__save (/var/task/node_modules/mongoose/lib/model.js:369:5)",
        "    at async model.save (/var/task/node_modules/mongoose/lib/model.js:609:5)",
    ]
}

Current Environment:
Mongoose: 9.1.3
mongoose-bcrypt: 1.11.0
Node.js: 22.x
Runtime: AWS Lambda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions