Skip to content

olive_branch fails silently when combined with ActionController::Live #15

@patrickvinograd

Description

@patrickvinograd

In a project that was using olive_branch for its JSON API responses, I implemented a controller that involved streaming large PDF content, and used ActionController::Live to implement the streaming in the controller's #show method. The #show method worked fine, since olive_branch ignored the non-JSON content-type.

However, this controller had another method that returned JSON content and so olive_branch would coerce the content of the response. If I pass an x-key-inflection header to this method, it fails - response headers come back, but no response body. No error/stack trace is generated. And, the rails connection/thread hangs - if I generate enough of these responses eventually I'll start getting ActiveRecord connection pool exhaustion because resources are not getting released.

It makes sense that olive_branch can't replace the response body because if it's being streamed, it will not have access to the entire response, only a chunk at a time. And ActionController::Live marks the response as committed as soon as the first byte is written. But, the failure mode is very pernicious and hard to diagnose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions