Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7.1 deprecation notice for cache_format_version in Rails test environment #114

Closed
asgeo1 opened this issue May 9, 2024 · 5 comments · Fixed by #120
Closed

Rails 7.1 deprecation notice for cache_format_version in Rails test environment #114

asgeo1 opened this issue May 9, 2024 · 5 comments · Fixed by #120

Comments

@asgeo1
Copy link

asgeo1 commented May 9, 2024

This line of code in this gem, is producing a deprecation warning with Rails 7.1

config.graphql_fragment_cache.store = :null_store

But only in the test environment.

DEPRECATION WARNING: Support for `config.active_support.cache_format_version = 6.1` has been deprecated and will be removed in Rails 7.2

It doesn't matter if you set config.active_support.cache_format_version = 7.1 in the Rails environment or intializer, the deprecation warning will still happen.

This is because that line of code is executing before Rails gets a chance to boot and set the correct cache_format_version.

If using RSpec, a possible workaround for now, is in rails_helper.rb to set the cache format version prior to the gem being loaded. e.g.

require "spec_helper"

# NOTE: this is a fix for graphql-fragment_cache, which is initializing it's own cache in the test environment
require "active_support/cache"
ActiveSupport::Cache.format_version = 7.1

require File.expand_path("../config/environment", __dir__)
require "rspec/rails"

RSpec.configure do |config|
  ...
@asgeo1 asgeo1 changed the title Rails 7.1 deprecation notice for cache_format_version Rails 7.1 deprecation notice for cache_format_version in Rails test environment May 9, 2024
@Drowze
Copy link
Contributor

Drowze commented Jul 18, 2024

I can confirm this is still an issue in latest rails version (v7.1.3.4) along with latest graphql-ruby-fragment_cache version (v1.20.2)

The line where the warning happens is now different though:

store = ActiveSupport::Cache.lookup_store(store)

For now I'm using the suggested workaround as well (setting format_version before the gem is loaded in test environment).

@noma4i
Copy link
Contributor

noma4i commented Aug 29, 2024

@DmitryTsepelev Rails 7.2 is out and the cache_format_version was removed.

@DmitryTsepelev
Copy link
Owner

@asgeo1 @Drowze @noma4i Hey! This should probably be a fix #118. I do not have any app that uses the gem right now, could you please try the fix out before I merge it in?

@DmitryTsepelev
Copy link
Owner

Fix is here #119, will be a part of the next release, thanks @noma4i 🙂

@Drowze
Copy link
Contributor

Drowze commented Oct 14, 2024

Just upgraded from 1.20.2 to 1.20.4 and it seems fixed now! Thank you! 😄

EDIT: ops! too early! It seems the warning is back:
Screenshot 2024-10-16 at 07 55 39

The issue is that Rails.application evaluates to nil at the time the railtie is loaded. I think simply adding a initializer block should fix the problem (so setting the cache store to null happens as part of the rails initialization process, after Rails.application is actually defined).

Tried to tackle this issue and opened PR at #120 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants