bertramdev / asset-pipeline

The core implementation of the asset pipeline for the jvm
194 stars 92 forks source link

Verify: order of the AssetPipelineFilter inside the filterChain #226

Closed davidkron closed 4 years ago

davidkron commented 6 years ago

Currently AssetPipelineFilter doesn't specify any order and gets placed after GrailsWebRequestFilter. In my opinion this is not correct and should be reevaluated as an asset request doesn't need a GrailsWebRequest and should therefore be placed before GrailsWebRequestFilter.

This has actually caused some side-effects in a production application of us: One thing the GrailsWebRequestFilter does is managing the flash scope. As the AssetPipelineFilter comes after GrailsWebRequestFilter, every request to an asset file will clear the flash scope, which can produce some interesting race conditions.

Also this causes some minimal performance overhead by creating and destroying a GrailsWebRequest.

davydotcom commented 6 years ago

It used to be prefixing it... what grails version is this

On Fri, Sep 7, 2018, 6:38 AM davidkron notifications@github.com wrote:

Currently AssetPipelineFilter doesn't specify any order and gets placed after GrailsWebRequestFilter. In my opinion this is not correct and should be reevaluated as an asset request doesn't need a GrailsWebRequest and should therefore be placed before GrailsWebRequestFilter.

This has actually caused some side-effects in a production application of us: One thing the GrailsWebRequestFilter does is managing the flash scope. As the AssetPipelineFilter comes after GrailsWebRequestFilter, every request to an asset file will clear the flash scope, which can produce some interesting race conditions.

Also this causes some minimal performance overhead by creating and destroying a GrailsWebRequest.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bertramdev/asset-pipeline/issues/226, or mute the thread https://github.com/notifications/unsubscribe-auth/AABaEsIVKUvb4oQ_DvS2C4NZ_UPULHycks5uYky3gaJpZM4WemS- .

davidkron commented 6 years ago

I just tested with a new grails 3.3.8 project from http://start.grails.org. Also we have some grails 3.1.x applications in production, where I discovered the behavior.

In both these versions the GrailsWebRequestFilter comes before AssetPipelineFilter.

ivo-k commented 4 years ago

I could workaround the issue by adding the following to config in application.groovy //FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER + 29 beans.assetPipelineFilter.order = 29

davydotcom commented 4 years ago

set order to 0 in 3.2.3 coming out today