This came up as an issue on Bandit recently, and is honestly something I’ve never thought about before. The situation is this:
-
The underlying server (either Bandit or Cowboy) receives a connection from the client, creates a Plug.Conn struct and passes it to the configured Plug module in process A.
-
Within
Plug.call/2
, details of the Plug.Conn structure get passed to another process, process B (the details of how this happens aren’t important here). -
Process B then attempts to call functions on Plug.Conn (say Plug.Conn.send_resp/3 for the sake of argument) using this Plug.Conn structure.
My question is: what should happen here?
It seems as if Cowboy allows this, and Bandit does as well for HTTP/1 connections. I have a check in Bandit’s HTTP/2 implementation that requires any calls to come from the process that Plug.call/2
was originally called from, but now that I think about it such a requirement is never explicitly called out as part of the Plug API contract. It strikes me that allowing this would open the door to any number of oddball concurrency issues however.
Do we collectively have a strong opinion on this one way or the other?