fxn/zeitwerk

Unlucky raise by rack-timeout causes missing constant

Closed this issue · 3 comments

We had an unlucky raise by rack-timeout, just as ruby was requiring a file. Relevant stacktrace:

Rack::Timeout::RequestTimeoutException: Request waited 2ms, then ran for longer than 14998ms 
  File "<internal:/app/vendor/ruby-3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>", line 37, in require
  File "<internal:/app/vendor/ruby-3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>", line 37, in require
  File "/app/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb", line 32, in require
  File "/app/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.8/lib/zeitwerk/kernel.rb", line 38, in require
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/attachments/trix_conversion.rb", line 12, in fragment_by_converting_trix_attachments
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/attachment.rb", line 15, in fragment_by_canonicalizing_attachments
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/content.rb", line 13, in fragment_by_canonicalizing_content
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/content.rb", line 23, in initialize
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/serialization.rb", line 9, in new
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/serialization.rb", line 9, in load
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/type/serialized.rb", line 22, in deserialize
  File "/app/vendor/bundle/ruby/3.2.0/gems/activemodel-7.0.4.3/lib/active_model/attribute_set/builder.rb", line 52, in block in fetch_value
  File "/app/vendor/bundle/ruby/3.2.0/gems/activemodel-7.0.4.3/lib/active_model/attribute_set/builder.rb", line 46, in fetch
  File "/app/vendor/bundle/ruby/3.2.0/gems/activemodel-7.0.4.3/lib/active_model/attribute_set/builder.rb", line 46, in fetch_value
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/attribute_methods/read.rb", line 38, in _read_attribute
  File "/app/vendor/bundle/ruby/3.2.0/gems/activemodel-7.0.4.3/lib/active_model/attribute_methods.rb", line 277, in body
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/app/models/action_text/rich_text.rb", line 12, in nil?
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/associations/association.rb", line 68, in reload
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/associations/singular_association.rb", line 11, in reader
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/associations/builder/association.rb", line 104, in rich_text_important_information
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/attribute.rb", line 40, in important_information?
....

This lead to each subsequent request which hit that code path to raise NameError: uninitialized constant ActionText::Attachments::TrixConversion::Fragment. Relevant stacktrace:

NameError: uninitialized constant ActionText::Attachments::TrixConversion::Fragment
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/attachments/trix_conversion.rb", line 12, in fragment_by_converting_trix_attachments
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/attachment.rb", line 15, in fragment_by_canonicalizing_attachments
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/content.rb", line 13, in fragment_by_canonicalizing_content
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/content.rb", line 23, in initialize
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/serialization.rb", line 9, in new
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/serialization.rb", line 9, in load
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/type/serialized.rb", line 22, in deserialize
  File "/app/vendor/bundle/ruby/3.2.0/gems/activemodel-7.0.4.3/lib/active_model/attribute_set/builder.rb", line 52, in block in fetch_value
  File "/app/vendor/bundle/ruby/3.2.0/gems/activemodel-7.0.4.3/lib/active_model/attribute_set/builder.rb", line 46, in fetch
  File "/app/vendor/bundle/ruby/3.2.0/gems/activemodel-7.0.4.3/lib/active_model/attribute_set/builder.rb", line 46, in fetch_value
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/attribute_methods/read.rb", line 38, in _read_attribute
  File "/app/vendor/bundle/ruby/3.2.0/gems/activemodel-7.0.4.3/lib/active_model/attribute_methods.rb", line 277, in body
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/app/models/action_text/rich_text.rb", line 12, in nil?
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/associations/association.rb", line 68, in reload
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/associations/singular_association.rb", line 11, in reader
  File "/app/vendor/bundle/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/associations/builder/association.rb", line 104, in rich_text_description
  File "/app/vendor/bundle/ruby/3.2.0/gems/actiontext-7.0.4.3/lib/action_text/attribute.rb", line 36, in description
....

Restarting the process resolved the issue.

I'm not sure this if this is a bug in zeitwerk, bootsnap, or just something that can happen with arbitrary error raising by rack-timeout.

fxn commented

Action Text is not loaded by Zeitwerk, could you please open this issue in the Rails repository?

Right, sorry about that! Rails issue: rails/rails#49064

fxn commented

No prob! :)