Surprising behaviour when recompiling in iex with a running process

In terms of code_change, there is discussion here about that (sorry, I don’t know much about it).

Otherwise, it sounds like you have the fairly common erroneous mental model that modules “own” processes. The two are actually unrelated. While the GenServer pattern does associate a module with a process that is merely an application pattern not enforced by the VM or anything like that. In the case of a GenServer, you’re just telling the process “Hey, call these function from this module when certain events happen,” but there is nothing stopping you from running unrelated code on that same process. All that to say that if a module changes, that has no inherent bearing on the process itself.

3 Likes