I have a Rails 7.0.1 test application that when it tries to load in multiple images (more than 2) it can regularly fail to load one or more images: on my dev system it happens most of the time.
Each time it fails you get the same 500 error: nil can't be coerced into Float (TypeError) from activesupport instrumenter. This happens on Rails 7.0 only and not on the almost identical 6.1 version.
Rails 7.0.1 - fails to load one of the images most of the time.

Rails 6.1 - never seen if fail

Stack trace
Code that throws the exception is here
Puma caught this error: nil can't be coerced into Float (TypeError)
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/activesupport-7.0.1/lib/active_support/notifications/instrumenter.rb:133:in `-'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/activesupport-7.0.1/lib/active_support/notifications/instrumenter.rb:133:in `duration'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/activesupport-7.0.1/lib/active_support/core_ext/enumerable.rb:61:in `map'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/activesupport-7.0.1/lib/active_support/core_ext/enumerable.rb:61:in `sum'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/activesupport-7.0.1/lib/active_support/core_ext/enumerable.rb:298:in `sum'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/middleware/server_timing.rb:26:in `block in call'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/middleware/server_timing.rb:25:in `each'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/middleware/server_timing.rb:25:in `map'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/middleware/server_timing.rb:25:in `call'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/middleware/static.rb:23:in `call'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/actionpack-7.0.1/lib/action_dispatch/middleware/host_authorization.rb:137:in `call'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/railties-7.0.1/lib/rails/engine.rb:530:in `call'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/puma-5.5.2/lib/puma/configuration.rb:249:in `call'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/puma-5.5.2/lib/puma/request.rb:77:in `block in handle_request'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/puma-5.5.2/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/puma-5.5.2/lib/puma/request.rb:76:in `handle_request'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/puma-5.5.2/lib/puma/server.rb:447:in `process_client'
/Users/me/.asdf/installs/ruby/3.0.3/lib/ruby/gems/3.0.0/gems/puma-5.5.2/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
Steps to reproduce
I have a couple of apps one which works based on 6.1 and another that doesn't work based on 7.0.1
- Clone repo
- cd into rails directory
- bin/setup (standard setup except it runs db:seed)
- Repeat the following steps until you notice an image not loading
- bin/rails server
- browser opens localhost:3000 and keep "Network" tab open
- check if the 10 images all loaded
- close rails server and back to step i (It's important to stop server as normally once images loads they keep loading)
- Check network tab for the image that failed to load and look at the response
Browser Network tab showing exceptions

There's very little code changes in the example applications. Basically:
- new application
- scaffold product
- install active_storage
- product has_one_attached image
- seed products with images
- Start running the server following the steps to reproduce ...
I've also tried:
- With Rails 7.0 displaying static images from public - loads it fine.
- All the browsers show the same issue
- Rails 6.1 version works with or without spring but with spring every now and then it could hang until you did a
spring stop.
- Larger images 300 x 300 also failed in similar manner and not noticeably more often.
Expected behavior
It should load the images every time.
Actual behavior
Most of the time in the test application it fails
System configuration
Rails 7.0.1
Ruby 3.0.3
I have a Rails 7.0.1 test application that when it tries to load in multiple images (more than 2) it can regularly fail to load one or more images: on my dev system it happens most of the time.
Each time it fails you get the same 500 error:
nil can't be coerced into Float (TypeError)from activesupport instrumenter. This happens on Rails 7.0 only and not on the almost identical 6.1 version.Rails 7.0.1 - fails to load one of the images most of the time.
Rails 6.1 - never seen if fail
Stack trace
Code that throws the exception is here
Steps to reproduce
I have a couple of apps one which works based on 6.1 and another that doesn't work based on 7.0.1
Browser Network tab showing exceptions
There's very little code changes in the example applications. Basically:
I've also tried:
spring stop.Expected behavior
It should load the images every time.
Actual behavior
Most of the time in the test application it fails
System configuration
Rails 7.0.1
Ruby 3.0.3