Skip to content

VersionError invokes error middleware with null document on save() #15480

Closed
@unc0ded

Description

@unc0ded

Prerequisites

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

Issue

I am aware what causes the VersionError and also checked other issues where people reported a null value for the document in the error-handling middleware. My question is a combination of these, perhaps more of a general one: why does a VersionError on a .save() not make the document available in the middleware? Is it an intentional decision?

I have checked the source code here:

return callback(err);

Also went through other cases where the callback is invoked with the document and other places it's not. How is this determined? I have some code in an error-handling middleware which depends on the document being available, hence wanted to know what to expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions