Skip to content

TypeError: this.$__setSchema is not a function #14281

@adamreisnz

Description

@adamreisnz

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8.0.2

Node.js version

21.6

MongoDB server version

7.0

Typescript version (if applicable)

n/a

Description

Our error reporting tool captured the following error, which originated from Mongoose and seems to be an internal Mongoose error where the __setSchema function appears to be missing:

Steps to Reproduce

TypeError: this.$__setSchema is not a function
node_modules/mongoose/lib/document.js in Mongoose.Document at line 91:10

  options = Object.assign({}, options);
  // Support `browserDocument.js` syntax
  if (this.$__schema == null) {
    const _schema = utils.isObject(fields) && !fields.instanceOfSchema ?
      new Schema(fields) :
      fields;
    this.$__setSchema(_schema);
    fields = skipId;
    skipId = options;
    options = arguments[4] || {};
  }
  this.$__ = new InternalCache();
node_modules/mongoose/lib/model.js in Mongoose.Model at line 125:12

Don't have exact schema's or an isolated reproducible case at this stage, but if the method has truly been removed or renamed it should be easy to track down.

Expected Behavior

No error to be thrown

Metadata

Metadata

Assignees

No one assigned

    Labels

    priorityAutomatically set for Mongoose Pro subscribers

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions