Multiple ways to short-circuit pipeline is a poor design and should be reconsidered #54548
Labels
area-hosting
Includes Hosting
design-proposal
This issue represents a design proposal for a different issue, linked in the description
✔️ Resolution: Answered
Resolved because the question asked by the original author has been answered.
question
Status: Resolved
Summary
Having the ability to call Run on the pipeline is confusing because you can have multiple calls to it and get no error, and the last element in the pipeline is effectively a Run anyway. Run has no logical difference to Use if the middleware in the Use call short-circuits. I propose removing Run because it can cause Use calls to be skipped and there is no error to inform the programmer of this issue.
Motivation and goals
Risks / unknowns
The risk is that is a breaking change, some might be using the Run call.
Examples
There are two ways to short-circuit:
By not calling
next.Invoke()
...And by calling
app.Run
instead ofapp.Use
like so...Run is signalling to the programmer that no more pipeline elements will execute, whereas app.Use may or may not short-circuit. If Run is intended, why not just order the pipeline correctly so that the last item in the chain is the last item? The naming of Run is also ambiguous with the later call to Run which looks visually unappealing as if it were a bug when it isn't.
The text was updated successfully, but these errors were encountered: