Conversation
Instead of defining errors that aren't defined, only add the errors if
they are defined.
If SQLite3 isn't defined, it should not be defined by Rpush.
Other dependencies could break if they use logic to test for defined constants.
This fixes an issue with Zeitwerk 2.8 where it tries to load a file named sqlite3:
[2026-05-29 14:08:00][ERROR] Failed to load 'active_record' storage backend.:20
[2026-05-29 14:08:00][ERROR] LoadError, cannot load such file -- sqlite3
/usr/lib/ruby/versions/3.4.9/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
/usr/lib/ruby/versions/3.4.9/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
/vendor/bundle/ruby/3.4.0/gems/bootsnap-1.24.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in 'Kernel#require'
/vendor/bundle/ruby/3.4.0/gems/zeitwerk-2.8.0/lib/zeitwerk/core_ext/kernel.rb:34:in 'Kernel#require'
/vendor/bundle/ruby/3.4.0/gems/rpush-9.2.0/lib/rpush/daemon/store/active_record/reconnectable.rb:13:in '<top (required)>'
/usr/lib/ruby/versions/3.4.9/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
/usr/lib/ruby/versions/3.4.9/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
/vendor/bundle/ruby/3.4.0/gems/bootsnap-1.24.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:33:in 'Kernel#require'
/vendor/bundle/ruby/3.4.0/gems/zeitwerk-2.8.0/lib/zeitwerk/core_ext/kernel.rb:34:in 'Kernel#require'
/vendor/bundle/ruby/3.4.0/gems/rpush-9.2.0/lib/rpush/daemon/store/active_record.rb:3:in '<top (required)>'
/usr/lib/ruby/versions/3.4.9/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
/usr/lib/ruby/versions/3.4.9/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
/vendor/bundle/ruby/3.4.0/gems/bootsnap-1.24.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:33:in 'Kernel#require'
/vendor/bundle/ruby/3.4.0/gems/zeitwerk-2.8.0/lib/zeitwerk/core_ext/kernel.rb:34:in 'Kernel#require'
brethren
left a comment
There was a problem hiding this comment.
Verified against the Ruby 3.4.10 / Rails 7.2 / Zeitwerk 2.8 failure in a PostgreSQL-only deployment. This avoids autoloading or defining unused adapter constants while preserving reconnect handling for adapters that are actually loaded.
|
@benlangfeld Could you please review and merge this? We reproduced the reported failure in a PostgreSQL-only deployment using Ruby 3.4.10, Rails/Active Record 7.2.3.2, and Zeitwerk 2.8.3: Failed to load the active_record storage backend: LoadError, cannot load such file -- sqlite3, from rpush-9.2.0/lib/rpush/daemon/store/active_record/reconnectable.rb:13. Applying this one-file change to the 9.2.0 image resolves startup without installing SQLite or defining unused adapter constants. I reviewed and approved the PR; our account does not have merge access to this repository. A tagged release containing it would let downstream applications remove their temporary vendored patch. |
Instead of defining errors that aren't defined, only add the errors if they are defined.
If SQLite3 isn't defined, it should not be defined by Rpush. Other dependencies could break if they use logic to test for defined constants.
This also prevents issues where some of the error classes start inheriting from other classes than StandardError.
This fixes an issue with Zeitwerk 2.8 where it tries to load a file named sqlite3 (in an application that doesn't use sqlite3):