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

Core methods doesn't work in configuration block after upgrading Falcon to 0.44 #236

Open
Exterm1nate opened this issue Apr 23, 2024 · 1 comment

Comments

@Exterm1nate
Copy link

After upgrading Falcon from 0.43 to 0.44 this configuration:

# falcon.rb

load :rack

rack File.basename(__dir__) do
  endpoint do
    Async::HTTP::Endpoint.for(scheme, "0.0.0.0", port: Integer(3000), protocol: protocol)
  end
  count Integer(2)
end

breaks server boot with a very strange error:

/home/kirill/gems/ruby-3.3.0/gems/async-service-0.12.0/lib/async/service/environment.rb:124:in `block (2 levels) in wrap': wrong number of arguments (given 1, expected 0) (ArgumentError)
	from /home/kirill/Desktop/my_project/falcon.rb:7:in `block (2 levels) in load_file'
	from /home/kirill/gems/ruby-3.3.0/gems/async-service-0.12.0/lib/async/service/environment.rb:125:in `block (2 levels) in wrap'
	from /home/kirill/gems/ruby-3.3.0/gems/falcon-0.45.2/lib/falcon/service/server.rb:38:in `start'
	from /home/kirill/gems/ruby-3.3.0/gems/async-service-0.12.0/lib/async/service/controller.rb:48:in `block in start'
	from /home/kirill/gems/ruby-3.3.0/gems/async-service-0.12.0/lib/async/service/controller.rb:47:in `each'
	from /home/kirill/gems/ruby-3.3.0/gems/async-service-0.12.0/lib/async/service/controller.rb:47:in `start'
	from /home/kirill/gems/ruby-3.3.0/gems/async-container-0.18.0/lib/async/container/controller.rb:203:in `run'
	from /home/kirill/gems/ruby-3.3.0/gems/async-service-0.12.0/lib/async/service/controller.rb:32:in `run'
	from /home/kirill/gems/ruby-3.3.0/gems/falcon-0.45.2/lib/falcon/command/host.rb:41:in `call'
	from /home/kirill/gems/ruby-3.3.0/gems/samovar-2.3.0/lib/samovar/command.rb:21:in `call'
	from /home/kirill/gems/ruby-3.3.0/gems/falcon-0.45.2/bin/falcon-host:26:in `<top (required)>'
	from bin/falcon-host:27:in `load'
	from bin/falcon-host:27:in `<main>'

After some investigation I found that configuration block rack {} doesn't support Ruby core methods anymore, e.g. puts, Integer(), etc.

Changing count Integer(2) to count 2 fixes the server boot and works well.

Also it is rather strange that block endpoint {} inside rack {} do support all these methods, that are breaking the rack {} itself. For example, you can use Integer() inside.

# falcon.rb

load :rack

rack File.basename(__dir__) do
  endpoint do
    Async::HTTP::Endpoint.for(scheme, "0.0.0.0", port: Integer(3000), protocol: protocol)
  end
  count 2
end

I suppose this should be fixed or at least mentioned in docs.

@ioquatix
Copy link
Member

ioquatix commented Apr 23, 2024

Yep that's a fair point, and a fair request. I'll think about the best way forward.

Part of the design motivation is to ensure we don't accidentally leak shared memory into the configurations, but it's pretty inconvenient. Those configuration blocks are actually re-evaluated every time the child is forked/executed to ensure isolation and predictable behaviour.

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