Calling GenServer.start_link from the controller means the newly-started processes will be terminated when the controller process terminates. Exactly how important this is depends on how long TransactionSubscriptionHandler processes are expected to live.
I can’t speak to any particular issues with your GenServer (not posted), but there are some issues with the controller:
jsonsends the response so it shouldn’t be called repeatedly. It will give aPlug.Conn.AlreadySentErrorif it is passed aconnthat knows the response has already been sent- also,
call_hashneeds to return the updatedconnafter using it. This is likely the cause of the unusual error deep in the internals ofcowboy_http: the second call tocall_hashgets passed aconnwhich is out-of-sync with the underlying Cowboy machinery
To fix this, you’ll need to decide what getting an error partway through the list of hashes should do - stop and leave the existing processes? Clean up? Keep going? - and then whatever makes that decision can render a JSON response.






















