You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uses Code.ensure_loaded/1 which is not sufficient if the adapter module is defined within the same application as the mailer module, as Code.ensure_loaded/1 does not wait for the module to be compiled, so depending on the order compilation goes, the check may fail.
Steps to Reproduce the Bug or Issue
It is hard to reproduce since it is a race condition but we have isolated the root case.
Expected behavior
One quick fix is to use Code.ensure_compiled/1. However, my suggestion is to move the @on_load check altogether to compile-time (via @before_compile/@after_compile callbacks) and use Code.ensure_compiled there. I don't see the need to check for this at runtime. The way Elixir manages your dependencies, you should assume that if a module is available at compile-time, it will be available at runtime.
Thank you!
Your reproducible example
No response
Screenshots or Videos
No response
Platform
It happens in any Erlang/OTP and Elixir version, but some versions may be more likely than others depending on how fast compilation goes.
Additional context
Thank you! ❤️
The text was updated successfully, but these errors were encountered:
Describe the bug
Initially reported here: elixir-lang/elixir#12777
This code:
https://github.com/swoosh/swoosh/blob/v1.11.3/lib/swoosh/mailer.ex#L236-L256
Uses
Code.ensure_loaded/1
which is not sufficient if the adapter module is defined within the same application as the mailer module, asCode.ensure_loaded/1
does not wait for the module to be compiled, so depending on the order compilation goes, the check may fail.Steps to Reproduce the Bug or Issue
It is hard to reproduce since it is a race condition but we have isolated the root case.
Expected behavior
One quick fix is to use
Code.ensure_compiled/1
. However, my suggestion is to move the@on_load
check altogether to compile-time (via @before_compile/@after_compile callbacks) and useCode.ensure_compiled
there. I don't see the need to check for this at runtime. The way Elixir manages your dependencies, you should assume that if a module is available at compile-time, it will be available at runtime.Thank you!
Your reproducible example
No response
Screenshots or Videos
No response
Platform
It happens in any Erlang/OTP and Elixir version, but some versions may be more likely than others depending on how fast compilation goes.
Additional context
Thank you! ❤️
The text was updated successfully, but these errors were encountered: