Currently, it's possible to apply the compression middleware multiple times, which has undesirable effects. This is particularly easy to do when using Express's Router, as a given Router can install compression but have it bleed into all subsequent middleware & handlers.
This PR introduces a flag on Response objects indicating whether compression has been injected into the response methods, and uses that flag to avoid re-injecting compression.
Issues: this might break composability? I don't know if people have valid use-cases for running multiple instances of this middleware today.
Currently, it's possible to apply the compression middleware multiple times, which has undesirable effects. This is particularly easy to do when using Express's
Router
, as a given Router can install compression but have it bleed into all subsequent middleware & handlers.This PR introduces a flag on Response objects indicating whether compression has been injected into the response methods, and uses that flag to avoid re-injecting compression.
Issues: this might break composability? I don't know if people have valid use-cases for running multiple instances of this middleware today.