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

Docs for "Triggering Another Route" result in infinite recursion #256

Closed
Phrogz opened this issue Apr 29, 2011 · 2 comments
Closed

Docs for "Triggering Another Route" result in infinite recursion #256

Phrogz opened this issue Apr 29, 2011 · 2 comments

Comments

@Phrogz
Copy link

Phrogz commented Apr 29, 2011

Running this code under 1.2.3 and requesting "/foo" results in 100% CPU usage and massive log output as the application keeps calling the same route again and again:

 tmp.rb:3:in `block in <main>'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:1165:in `call'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:1165:in `block in compile!'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:738:in `instance_eval'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:738:in `route_eval'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:722:in `block (2 levels) in route!'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:772:in `block in process_route'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:769:in `catch'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:769:in `process_route'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:721:in `block in route!'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:720:in `each'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:720:in `route!'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:857:in `dispatch!'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:648:in `block in call!'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:822:in `instance_eval'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:822:in `block in invoke'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:822:in `catch'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:822:in `invoke'
 C:/Ruby/lib/ruby/gems/1.9.1/gems/sinatra-1.2.3/lib/sinatra/base.rb:648:in `call!'

It looks like that PATH_INFO is pulled not from the environment directly but from the duplicated environment's Sinatra::Request object. For a working hack to accomplish this same goal, see this Stack Overflow answer.

I'm not sure if

  1. the issue here is that a legitimate change has been made and the documentation needs to be updated, or
  2. if what the documentation suggests should still work and there is a recently-introduced bug in the route handling of Sinatra.
@rkh
Copy link
Member

rkh commented Apr 29, 2011

It is a recently introduced bug and already fixed both in master and the 1.2.x branch. I will release 1.2.4 with the fix this weekend.

@rkh rkh closed this as completed Apr 29, 2011
@Phrogz
Copy link
Author

Phrogz commented Apr 29, 2011

Ah! Excellent. I wish I had posted this before I spent three hours finding and implementing the workaround. :p Thanks!

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