Skip to content

Commit

Permalink
fix: avoid throwing error if saveOptions undefined when invalidating …
Browse files Browse the repository at this point in the history
…subdoc cache

Fix #15062
  • Loading branch information
vkarpov15 committed Dec 3, 2024
1 parent f5f7be9 commit 76f92d2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/plugins/saveSubdocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ module.exports = function saveSubdocs(schema) {
cb(err);
});
}, function(error) {
// Bust subdocs cache because subdoc pre hooks can add new subdocuments
_this.$__.saveOptions.__subdocs = null;
// Invalidate subdocs cache because subdoc pre hooks can add new subdocuments
if (_this.$__.saveOptions) {
_this.$__.saveOptions.__subdocs = null;
}
if (error) {
return _this.$__schema.s.hooks.execPost('save:error', _this, [_this], { error: error }, function(error) {
next(error);
Expand Down

0 comments on commit 76f92d2

Please sign in to comment.