Skip to content


Thread locking errors using Rack::JSONP #46

jasonschock opened this Issue · 0 comments

2 participants


I have a very simple API using the Rack::JSONP module and am getting a 503 response with "recursive locking" error on my local development machine, as well as on Heroku. This happens with both Thin and WebBrick. The error happens quite often, sometimes every other request. As soon as I remove the callback= param from the query string, or remove the rack/contrib stuff from, no more problem. Sorry, don't know much about threads + rack, or why this might be happening.

  • Mac OS 10.7.2 and Heroku Cedar
  • Rails 3.1.3
  • Ruby 1.9.2-p290

My Gemfile (tried several gem versions):

gem 'rack-contrib', :git => ''


require 'rack/contrib'
use Rack::JSONP

Sample request:


My controller is very simple:

class Api::V1::BasketItemsController < Api::V1::BaseController
  respond_to :json

  def new


Sample error from WebBrick:

[2012-01-04 17:53:04] ERROR ThreadError: deadlock; recursive locking
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/lock.rb:14:in `lock'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/lock.rb:14:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.3/lib/action_dispatch/middleware/static.rb:53:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/engine.rb:456:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rack-contrib-acdcb256bb6e/lib/rack/contrib/jsonp.rb:31:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/content_length.rb:14:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/rack/log_tailer.rb:14:in `call'
    /Users/jason/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/handler/webrick.rb:59:in `service'
    /Users/jason/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
    /Users/jason/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
    /Users/jason/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

Sample Heroku error (thin):

2012-01-05T02:03:53+00:00 app[web.1]: !! Unexpected error while processing request: deadlock; recursive locking
2012-01-05T02:03:53+00:00 heroku[router]: Error H13 (Connection closed without response) -> GET dyno=web.1 queue= wait= service= status=503 bytes=
@jasonschock jasonschock added a commit to Grasket/rack-contrib that referenced this issue
@jasonschock jasonschock [Issue #46] Added .close to response to resolve some thread locking i…
@rkh rkh closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.