Commit 22ff9b78 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Try out the monkey patch to fix the middleware

which isn't properly cleaning up whenever something
is thrown, not raised. See:

https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1402#note_25128108
parent daa4590c
module LocalCacheRegistryCleanupWithEnsure
LocalCacheRegistry =
ActiveSupport::Cache::Strategy::LocalCache::LocalCacheRegistry
LocalStore =
ActiveSupport::Cache::Strategy::LocalCache::LocalStore
def call(env)
LocalCacheRegistry.set_cache_for(local_cache_key, LocalStore.new)
response = @app.call(env)
response[2] = ::Rack::BodyProxy.new(response[2]) do
LocalCacheRegistry.set_cache_for(local_cache_key, nil)
end
cleanup_after_response = true # ADDED THIS LINE
response
rescue Rack::Utils::InvalidParameterError
[400, {}, []]
ensure # ADDED ensure CLAUSE to cleanup when something is thrown
LocalCacheRegistry.set_cache_for(local_cache_key, nil) unless
cleanup_after_response
end
end
ActiveSupport::Cache::Strategy::LocalCache::Middleware
.prepend(LocalCacheRegistryCleanupWithEnsure)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment