Hello,
I have a phoenix app that serves user requests by fetching data from a storage backend and stream them to the client, taking selection parameters from the query string.
There are constraints that force me to first write the data locally on a scratch storage space and then only stream it.
Therefore, I added at the end of my pipeline a plug to clean the scratch after the data has been streamed to the user (with Plug.send_chunks).
Called like this at the very end of endpoint plug calls:
plug WsdataselectWeb.Plug.Cleanup
But in some cases (internal error when managing a request or client aborting the connection), the pipeline is broken and the cleanup plug is not called.
I feel that my strategy is not the best. Would you suggest another way to do this ?






















