You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
KernelEvents::TERMINATE will dispatch twice after push HttpCache to stack #10
This highlights a pretty interesting flaw in the current design of the stack. The stack assumes that every middleware will handle its own layer of termination. The stack just triggers every terminate() individually. However, this is not the case. Since a middleware is a decorator, if it implements terminate(), it will of course also call terminate() on the next layer!
As a result, it will be called once by stack, and once by the cache middleware itself.
The reason for doing this in the first place, is that terminable is optional. So because not every middleware of the chain has to implement it, the chain can be broken. The point of the stack is to never break this chain, and call all of the terminable middlewares.
I have some ideas for fixing the problem, but it is going to get a bit complicated.
Activity
igorw commentedon Nov 19, 2014
First of all, thanks so much for reporting this!
This highlights a pretty interesting flaw in the current design of the stack. The stack assumes that every middleware will handle its own layer of termination. The stack just triggers every terminate() individually. However, this is not the case. Since a middleware is a decorator, if it implements terminate(), it will of course also call terminate() on the next layer!
As a result, it will be called once by stack, and once by the cache middleware itself.
The reason for doing this in the first place, is that terminable is optional. So because not every middleware of the chain has to implement it, the chain can be broken. The point of the stack is to never break this chain, and call all of the terminable middlewares.
I have some ideas for fixing the problem, but it is going to get a bit complicated.
igorw commentedon Nov 19, 2014
It's... complicated.
Build safe chain of terminable kernels (fixes #10)
Assume Terminable middlewares will delegate (fixes #10)
Update CHANGELOG for v1.0.3, refs #10
igorw commentedon Nov 23, 2014
This issue has been fixed in v1.0.3, thanks so much for reporting it!