https://avo.cool logo
G'day folks. Tried upgrading our app to Rails 8...
# avo-3
a
G'day folks. Tried upgrading our app to Rails 8.1, mostly went okay but there was one hiccup that was causing the Rails console to bomb out when calling
reload!
that I traced back to this commit in Rails: https://github.com/rails/rails/commit/d43dc9af18766f91eb450e1c6b8c8c5e64f925e6 The basic gist of it is that
config.active_support.executor_around_test_case
defaults to
true
since Rails 7 and this causes the nesting behaviour of
ActiveSupport::ExecutionContext
to act as nested regardless of the environment you're in, although that nesting behaviour is only supposed to have any impact on the test environment. In our case, something in Avo's use of
ExecutionContext
in combination with our own app causes this new nesting behaviour to call
pop
too many times on the
ExecutionContext
, causing
@current_attribute_instances
to eventually become
nil
rather than the expected hash. This results in an exception after trying to reload in the console that reads:
Copy code
NoMethodError: undefined method '[]' for nil (NoMethodError)

        current_instances[current_instances_key] ||= new
                         ^^^^^^^^^^^^^^^^^^^^^^^
The workaround that we've put in is to just set
config.active_support.executor_around_test_case
to false in environments other than the test environment. So far so good, although we haven't tried the upgrade in production and won't be for a few weeks at least. I haven't been able to reproduce this behaviour in a minimal test case yet, so there may be something deeper in our app that intersects with this issue, but the error itself was consistent in terms of happening by way of
Avo::ExecutionContext#initialize
.
m
Thread automatically created by dark_panda in #1138182212655788054
l
Hi! Thanks for the detailed report and insights.
Avo::ExecutionContext
and
ActiveSupport::ExecutionContext
are two different classes. Since you can't reproduce it in a different repository, it's most likely that some configuration in your application is causing the error with
ActiveSupport::ExecutionContext
. I think it's unrelated to Avo. I'm curious whether the issue persists if you remove Avo from the project in development, though I understand that might not be easy to test
a
I've traced it back to a particular gem we were using that includes ActiveSupport::TestCase at an inopportune location in code. The Avo intersection was a bit of a red herring in that they're only related in so far as it was references to
Avo::Current
specifically that were floating around in the backtrace for us, so I'll be contacting the gem authors for that. The basic gist of it is: don't include test-related files in non-test-related environments willy nilly, 'cause this inclusion to me looks a little willy-nilly.
l
Got it, do you think there is something that can be done on avo to avoid it?
a
Just don't ever require any of the Rails
TestCase
classes, that's what sets it all off
at least not in non-test environments
l
Got it, which is the gem you're mentioning here btw?
a
Sorry for the delayed response, the gem in question is the Draper gem, see the report and PR here: https://github.com/drapergem/draper/issues/948
l
No problem, thanks for sharing!