Closed angus-c closed 5 years ago
Can you include a description of the reasoning for this change? Also, can we add a regression test, if this is fixing a bug?
I'm a bit confused by this, I think the asset plugin should go before any user/app plugins.
The disk asset serving should succeed/fail early on the downstream so that any user plugins can respond appropriately based on this (e.g S3 fallback, custom headers, etc.)
The disk asset serving should succeed/fail early on the downstream so that any user plugins can respond appropriately based on this (e.g S3 fallback, custom headers, etc.)
The reason we don't register this first is so the user can have middleware that run before. This allows the user to compose with the assets middleware to do things like add headers.
The reason we don't register this first is so the user can have middleware that run before. This allows the user to compose with the assets middleware to do things like add headers.
The asset plugin doesn't await next?
The reason we don't register this first is so the user can have middleware that run before. This allows the user to compose with the assets middleware to do things like add headers.
The asset plugin doesn't await next?
It does, and that is exactly why it needs to be registered last. Otherwise it will be the last thing to run, and we wont be able to have fallback mechanisms (such as s3).
It does, and that is exactly why it needs to be registered last. Otherwise it will be the last thing to run, and we wont be able to have fallback mechanisms (such as s3).
The asset plugin should set the response body on the downstream though, right?
It does, and that is exactly why it needs to be registered last. Otherwise it will be the last thing to run, and we wont be able to have fallback mechanisms (such as s3).
The asset plugin should set the response body on the downstream though, right?
Only if opts.defer
is false. As of several months ago its been true, which I think means it is set on the upstream
See: https://github.com/koajs/static/blob/master/index.js
test added. @rtsao do you still have qualms? See my opts.defer
true/false comment above.
Triggered Fusion.js build verification: https://buildkite.com/uberopensource/fusion-release-verification/builds/1772
We want the response to be sent as early as possible so other middlewares can react to
ctx.status