Sinatra as a Rails 3.1 middleware crashes app #352

Closed
rurounijones opened this Issue Sep 14, 2011 · 9 comments

Projects

None yet

2 participants

@rurounijones

I recently upgraded a rails 3.0 application to rails 3.1.

This Rails application has a very simple Sinatra app at the top of the middleware stack using

config.middleware.insert_before(Rack::Lock, Api::Version1)

which acts as an api endpoint only.

This crashes the application when using rails 3.1 and trying to access a URL handled by the rails app; accessing urls handled by the Sinatra app cause no trouble. The stacktrace (using webrick) is in this gist: https://gist.github.com/1216078

Reverting to rails 3.0 fixes the issue
Removing the Sinatra app from the middleware stack in 3.1 also fixes the issue.

Ruby 1.8.7
Tested with Sinatra 1.2.6 and master

I am not sure if this is a Sinatra / Rack / Rails problem. Assuming the problem isn't me being an idiot (please point out) I will try and make a very simple sample app that I can share.

@rurounijones

After actually kicking the brain in gear I had a look at things and changed

config.middleware.insert_before(Rack::Lock, Api::Version1)

to

config.middleware.insert_after(Rack::Lock, Api::Version1)

and that seems to have fixed it. I have no idea why it broke going from 3.0 to 3.1 but hey ho. I shall leave the ticket open in case anyone wants to investigate (Or tell me I have been an idiot and to close the ticket)

@rkh
Sinatra member

This is probably due to the changes in Rack::Lock, I'll investigate. If you have a minute, could you try running the insert_before version against Sinatra master?

@rkh rkh was assigned Sep 14, 2011
@rkh
Sinatra member

I've set up a 3.1 app, added a Sinatra middleware, added Rack::Protection separately, tried a few combinations but I was unable to produce any issues what so ever.

@rurounijones

Apologies for the delay, was on holidays.
Master still exhibits the problem on my app. Could you send me the link to the test app you made and I shall see if I can find some common ground that causes trouble.

@rkh
Sinatra member

Could you try running against a post 9c4ac4c master?

@rurounijones

Ok, will test on Monday

@rkh
Sinatra member

Cool, lemme know if you need anything. This is the only blocking issue for a 1.3 release.

@rurounijones

Excellent! Just tested with Sinatra master and the problem did not occur. Thank you very much!

@rkh
Sinatra member

Awesome! I see a release in the near future.

@rkh rkh closed this Sep 26, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment