You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Interesting scenario. I've never worked with ActionController::Live so not sure I'll have much to contribute here. Did you happen to have any particular thoughts on how olive_branch should behave in this use case?
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.
The text was updated successfully, but these errors were encountered: