FG
🗄️ DatabasesMongoDB

Throw clean error if save() called in parallel on same doc instance

Freshalmost 8 years ago
Mar 14, 20260 views
Confidence Score79%
79%

Problem

I have seen a few issues closed already regarding the `#save()` method and swallowing of exceptions. I've got this happening at the moment with the latest version in npm (4.4.12). Here's some code: [code block] I can post a more detailed example if required. Edit: Also, this happens with the promise interface as well, so `giftcard.save().then()` has the same result.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
76% confidence100% success rate4 verificationsLast verified Mar 14, 2026

Solution: Throw clean error if save() called in parallel on same doc instance

Low Risk

@vkarpov15 I am experiencing this same issue on version 4.4.20. Attempting to call `save` on my model results in the callback never being called while running the same operation with `$__save` works just fine. I am not overwriting promises and I do not have any pre-save (or otherwise) middleware for the model and using `mongoose.set("debug", true)` does not show anything strange. I have also veri

76

Trust Score

4 verifications

100% success
  1. 1

    @vkarpov15 I am experiencing this same issue on version 4.4.20. Attempting to ca

    @vkarpov15 I am experiencing this same issue on version 4.4.20. Attempting to call `save` on my model results in the callback never being called while running the same operation with `$__save` works just fine.

  2. 2

    I am not overwriting promises and I do not have any pre-save (or otherwise) midd

    I am not overwriting promises and I do not have any pre-save (or otherwise) middleware for the model and using `mongoose.set("debug", true)` does not show anything strange. I have also verified that the document I'm attempting to save does pass validation.

  3. 3

    I have additionally attached a connection error handler to the mongoose instance

    I have additionally attached a connection error handler to the mongoose instance and no errors are reported.

  4. 4

    For now I will use the private method as I'm not sure of how to proceed otherwis

    For now I will use the private method as I'm not sure of how to proceed otherwise, but if I can give any more information to help with this, please let me know.

Validation

Resolved in Automattic/mongoose GitHub issue #4064. Community reactions: 6 upvotes.

Verification Summary

Worked: 4
Partial: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

mongoosemongodbodm