Skip to content

Mounted Grape App -> Rack::Lint::LintError: Response body is already closed #2323

@ericproulx

Description

@ericproulx

Hi 👋,

I'm working on a feature to add linting in Grape by adding Rack::Lint in the stack. It works well but I'm encountering a Rack::Lint::LintError: Response body is already closed when a Grape API is mounted in a Rails app.

When calling it, Rails's middlewares stack will deal with a Rack::Lint::Wrapper body instead of the real one. This ain't the issue but if we look at Rack::Etag, it might call body.to_ary. Indeed, the to_ary function will be the one in Rack::Lint::Wrapper and it will close the body. Unfortunately, when calling each on it, it will raise a Rack::Lint::LintError even though our original linting was valid.

I've looked into Rack::Lint and somehow, it was setting @closed = false when calling each in Rack 2, but this is not the case anymore.

I've open an issue on our side if you want to take a look at my example.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions