I just spent two hours trying to find out why a middleware was unable to set a header, and it turns out this line of code violates this clause of the spec:
MUST return an instance that has the new and/or updated header and value.
The idea of a response being "complete" isn't even a thing in the spec.
Simply ignoring function calls in this manner makes it very hard to debug anything, and is extremely risky. If I called setHeader()
(or any number of other methods) clearly I'm calling them for one reason, and one reason only - quietly ignoring this call is a clear violation of the spec.
Debugging this type of silent error is an absolute nightmare. Components and middleware worked perfectly in unit and integration tests, but then quietly failed when implemented in production code.
I'm baffled as to why you would think this feature is necessary in the first place? Request and Response models are already immutable - what possible reason could you have to disable an an already-immutable model instance from generating a new model?
If a given piece of middleware decides that a response is "complete", quite simply, it won't delegate control to the next middleware on the stack. Instead, this feature allows you to delegate control to the next middleware, but disabling it from actually doing anything - it will run, but can't actually do anything.
Am I crazy for thinking this is crazy??
help wanted Awaiting author feedback