Skip to content

Bug: TemplateData pre-save hook uses next callback (Mongoose 9.x incompatible) #33

Description

@ChitkulLakshya

Bug: TemplateData pre-save hook uses next callback (Mongoose 9.x incompatible)

File: server/models/TemplateData.js:52-55

Problem

The pre-save hook uses the old Mongoose pattern with next callback:

TemplateDataSchema.pre('save', function (next) {
  this.updatedAt = new Date();
  next();
});

In Mongoose 9.x, the next parameter is no longer passed to pre('save') hooks. This causes TypeError: next is not a function on every TemplateData.create() or .save() call.

Fix

Remove the next callback — Mongoose 9.x automatically calls next() after the hook function returns:

TemplateDataSchema.pre('save', function () {
  this.updatedAt = new Date();
});

Severity

Critical — Every template creation/save throws an error. The sync endpoint and any future template writes are broken.

Status

Fix already exists in PR #29 (Phase 4). This issue tracks it for visibility.

Phase

Introduced in Phase 1 (PR #26, merged).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions