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

Rack responses may be frozen #40598

Closed
wants to merge 1 commit into from
Closed

Commits on Nov 10, 2020

  1. Rack responses may be frozen

    We are getting errors like this in our production rails app from this
    middleware:
    
         FrozenError: can't modify frozen Hash
    
    I'm not sure where the frozen response is coming from, but it seems like
    a thing which can happen -- even within rails, in
    ActionDispatch::Http::Response#before_sending:
    
        def before_sending
          # Normally we've already committed by now, but it's possible
          # (e.g., if the controller action tries to read back its own
          # response) to get here before that. In that case, we must force
          # an "early" commit: we're about to freeze the headers, so this is
          # our last chance.
          commit! unless committed?
    
          headers.freeze
          request.commit_cookie_jar! unless committed?
        end
    
    This middleware seems to take pains to avoid too much object churn, so
    the spirit has been followed here to only duplicate what is required to
    insert the header.
    sj26 committed Nov 10, 2020
    Configuration menu
    Copy the full SHA
    a5373ff View commit details
    Browse the repository at this point in the history