Skip to content

too short stack traces after nextTick call on document validation #1034

@kof

Description

@kof

I have a validation error:

TypeError: Cannot read property 'length' of undefined

Stacktrace (most recent call last):

File "/app/app/server/app/models/user.js", line 61, in model.
return str.length < 20;

File "/app/node_modules/mongoose/lib/schematype.js", line 345
validate(validator.call(scope, value), message);

File "native", line 0, in Array.forEach

File "/app/node_modules/mongoose/lib/schematype.js", line 333, in SchemaString.doValidate
this.validators.forEach(function (v) {

File "/app/node_modules/mongoose/lib/document.js", line 777, in Array.18
p.doValidate(self.getValue(path), function (err) {

File "node.js", line 190, in EventEmitter._tickCallback

Stacktrace there is a way too short, it starts from p.doValidate method call, so I am not able to understand which code is causing this validation issue.

The reason for this is nextTick call before it https://github.com/LearnBoost/mongoose/blob/master/lib/document.js#L847

Is there a real reason to use nextTick there and how do deal with this?

Best,
Oleg

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions