Rack Environment Modification Problems on Multiple Calls?

Taken from https://github.com/intridea/omniauth/issues/239 - I’m not sure what the issue might be here, wondering if someone on Rails core might know why this behavior is happening.

It seems that it’s even easier to reproduce. If you call the following line in a before_filter:

request.env[‘warden’].authenticate(:scope => :user)

and add a middleware looking like this (to simulate OmniAuth strategy that calls app twice, each time with different env):

class Kaboom

def initialize(app)

@app = app


def call(env)

@app.call(env.dup) # call 1

@app.call(env) # call 2



Then params[:controller] and params[:action] are missing in every request.

If you remove the before filter or change the first call in the middleware to @app.call(env) (without .dup) it works fine.