Skip to content

Conversation

jonatanklosko
Copy link
Member

@jonatanklosko jonatanklosko commented Oct 21, 2024

With IEx.configure(auto_reload: true), the iex mix listener will purge the recompiled modules immediately, without waiting for IEx.Helpers.recompile. Suggestions for the option name are welcome :)

Sidenote: given modules Foo and Bar, when Foo is called in IEx, it is loaded in the memory. When a concurrent compilation changes both Foo and Bar, calling Foo uses the old version of the module, however calling Bar uses the new version of the module, because it's loaded from disk for the first time. One option to address this inconsistency would be to make :auto_reload the default behaviour, however that could have undesired side effects, for example with iex -S mix phx.server it could reload module during a request. We decided to make it as an option for now.

@josevalim
Copy link
Member

@jonatanklosko I would prefer to not make it a configuration option but instead make it part of IEx.configure. This means people could set a default per project in their .iex.exs or even globally. Then we can check the status of the config whenever we receive an event. WDYT? I think auto_reload: true is fine as an option name. :)

@jonatanklosko
Copy link
Member Author

@josevalim sounds good, updated!

@josevalim josevalim merged commit 74beb7f into elixir-lang:main Oct 21, 2024
9 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@jonatanklosko jonatanklosko deleted the jk-iex-auto-reload branch October 21, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants