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

Railtie not loading #256

Open
p8 opened this issue Oct 23, 2024 · 3 comments
Open

Railtie not loading #256

p8 opened this issue Oct 23, 2024 · 3 comments

Comments

@p8
Copy link

p8 commented Oct 23, 2024

I've added Falcon to the Rails TechEmpower benchmark: TechEmpower/FrameworkBenchmarks#9339

I had to set the isolation_level to :fiber by hand to make it work.
https://github.com/p8/FrameworkBenchmarks/blob/f7822a3d79689164e372fba05be4ee744b1f42a4/frameworks/Ruby/rails/config/application.rb#L55

Otherwise the following error would occur:

$ ./tfb --test rails-falcon --mode verify
...
rails-falcon: {"time":"2024-10-23T08:13:36+00:00","severity":"error","oid":3416,"pid":18,"subject":"Protocol::Rack::Adapter::Rack3","annotation":"Reading HTTP/1.1 requests for Async::HTTP::Protocol::HTTP1::Server.","event":{"type":"failure","root":"/rails","class":"NoMethodError","message":"\u001b[1mundefined method 'map_types!' for nil (\u001b[1;4mNoMethodError\u001b[m\u001b[1m)\u001b[m\n\n\u001b[1m              result = conn.async_exec(sql).map_types!(@type_map_for_results).values\u001b[m\n\u001b[1m                                           ^^^^^^^^^^^\u001b[m","backtrace":
["/usr/local/bundle/gems/activerecord-7.2.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:19:in 'block (2 levels) in ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements#query'",
"/usr/local/bundle/gems/activerecord-7.2.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:1004:in 'block in ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection'",
"/usr/local/bundle/gems/activesupport-7.2.1.1/lib/active_support/concurrency/null_lock.rb:9:in 'ActiveSupport::Concurrency::NullLock#synchronize'",
"/usr/local/bundle/gems/activerecord-7.2.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:976:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#with_raw_connection'",
"/usr/local/bundle/gems/activerecord-7.2.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:18:in 'block in ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements#query'",
"/usr/local/bundle/gems/activesupport-7.2.1.1/lib/active_support/notifications/instrumenter.rb:58:in 'ActiveSupport::Notifications::Instrumenter#instrument'",
"/usr/local/bundle/gems/activerecord-7.2.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:1119:in 'ActiveRecord::ConnectionAdapters::AbstractAdapter#log'",
"/usr/local/bundle/gems/activerecord-7.2.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:17:in 'ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements#query'",
"/usr/local/bundle/gems/activerecord-7.2.1.1/lib/active_record/connection_adapters/abstract/database_statements.rb:110:in 'ActiveRecord::ConnectionAdapters::DatabaseStatements#query_values'",
"/usr/local/bundle/gems/activerecord-7.2.1.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:35:in 'ActiveRecord::ConnectionAdapters::SchemaStatements#data_sources'"
@ioquatix
Copy link
Member

I wonder if it's load order dependent?

https://github.com/socketry/falcon/blob/main/lib/falcon.rb#L10

@p8
Copy link
Author

p8 commented Oct 23, 2024

Yes, it could be that Rails isn't loaded there yet.

@ioquatix
Copy link
Member

I wonder what the best strategy would be, e.g.

begin
  require 'railtie'
  ...
rescue LoadError 
  # Ignore
end

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

No branches or pull requests

2 participants