Thanks for the answer !
The process per request approach was introduced 2 in cowboy 2.
I am indeed using Plug.Adapters.Cowboy2, so this process per request could explain it. Thanks a lot for the link to the documentation.
This is strange, though. What do you mean by “initializing my Ecto schema”? What happens on the line right after?
My create_report (with debug logs) looked like that
Logger.info("Reporting")
decoded_body = decode_body(response)
Logger.info("Decoded body #{decoded_body}")
changeset = Report.changeset(%Report{}, %{
...
}
Logger.info("Changeset #{inspect(changeset)"}
And on my several attemps I always got the first 2 logs, but never the last one. Maybe it was pure coincidence that Cowboy2 always terminated the process on the same line, but I started to wonder if Erlang scheduler waited for the first call to an external module to terminate my process.