-
Notifications
You must be signed in to change notification settings - Fork 29
Description
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.