Automattic / Automattic/mongoose

Resurrect from post save error middleware

Open
#5,464 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
27.5k
Forks
4k
Avg merge
2d 7h
Merged PRs (30d)
35

Description

**Do you want to request a *feature* or report a *bug*?**
Feature

**What is the current behavior?**
Once post save error middleware is reached it's not possible to return to the success path

**What is the expected behavior?**
A way to return from post save error middleware to resolve the initial promise

**Use case**
For instance handle a duplicate error (11000) by creating a new identifier which isn't a duplicate and resave the document returning the new save promise to the initial save call.

**Please mention your node.js, mongoose and MongoDB version.**
node 8.1.4, mongoose 4.11.1, mongo 3.4.6

Contributor guide

Open the contributing guide

Research direction

The issue names post-save error middleware, the initial save promise, and duplicate-key error 11000, but no files or tests. Start by tracing save handling and post-save error middleware, then reproduce the duplicate-key case with the stated Node.js, Mongoose, and MongoDB versions. Done means a middleware handler can resave with a new identifier and return that promise to the original save call.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb, node.js
Domain
backend, backend-api-design, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.