IvanRublev / Domo

A library to validate values of nested structs with their type spec t() and associated precondition functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Renaming/Removing modules requires a clean build

xpgdk opened this issue · comments

Environment

  • Elixir version (elixir -v): 1.14.0
  • Domo version (mix deps | grep domo | head -1): 1.5

Actual behavior

When removing/renaming a module that is using Domo, a mix clean is necessary to avoid compilation errors.
I think the problem is somewhere around loading of the BEAM types in ModuleInspector.beam_types/1.
For some reason CodeEvaluation.in_mix_compile?() evaluates to false, resulting in a call to ResolvePlanner.get_types/2, which doesn't work.

Expected behavior

Renaming and removing modules should not require cleaning.

Verbose output

could not compile dependency :XXX, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile XXX", update it with "mix deps.update XXX" or clean it with "mix deps.clean XXX"

** (exit) exited in: GenServer.call(Domo.TypeEnsurerFactory.ResolvePlanner, {:get_types, XXX.Shared.UUID}, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir 1.14.0) lib/gen_server.ex:1027: GenServer.call/3
    (domo 1.5.10) lib/domo/type_ensurer_factory/module_inspector.ex:40: Domo.TypeEnsurerFactory.ModuleInspector.beam_types_hash/1
    (domo 1.5.10) lib/domo/type_ensurer_factory/dependency_resolver.ex:82: anonymous fn/1 in Domo.TypeEnsurerFactory.DependencyResolver.get_dependant_module_hashes/1
    (elixir 1.14.0) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.14.0) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (domo 1.5.10) lib/domo/type_ensurer_factory/dependency_resolver.ex:81: Domo.TypeEnsurerFactory.DependencyResolver.get_dependant_module_hashes/1
    (domo 1.5.10) lib/domo/type_ensurer_factory/dependency_resolver.ex:16: Domo.TypeEnsurerFactory.DependencyResolver.maybe_recompile_depending_structs/3
    (domo 1.5.10) lib/domo/type_ensurer_factory.ex:349: Domo.TypeEnsurerFactory.recompile_depending_structs/4

That's true; there is no function that removes records about the dependencies from deps_path file when their modules can't be loaded anymore.
I think that function can be called before going to maybe_recompile_depending_structs/3 here: https://github.com/IvanRublev/Domo/blob/master/lib/mix/tasks.compile.domo_compiler.ex#L110

PR's are welcome!

Resolved in version 1.5.12. Please, have a look ✌️

Seems to be working in 1.5.12. Thank you very much @IvanRublev and @graupe for your quick work on this!

Seems to be working in 1.5.12. Thank you very much @IvanRublev and @graupe for your quick work on this!

Don't know about quick on my part ;-) Rough times. Sorry for hijacking your issue, I was trying to score a quick fix, to finally have our pipelines stop breaking so often.

Thanks for finishing, @IvanRublev, from where I left off and for the praise in the changelog.

Haha @xpgdk it depends on what you compare with. For me, it was pretty long but steady work acknowledging existing risks and limitations.

Wow, I didn't think about that from the CI/CD pipelines perspective.

I'm so happy that we finally fixed it together!