Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update utils.ex #111

Merged
merged 1 commit into from
Jun 5, 2022
Merged

Update utils.ex #111

merged 1 commit into from
Jun 5, 2022

Conversation

Adzz
Copy link
Contributor

@Adzz Adzz commented May 23, 2022

The docs for ensure_compiled specifically warn against doing this. To quote:

If the module being checked is currently in a compiler deadlock, this function returns {:error, :unavailable}. Unavailable doesn't necessarily mean the module doesn't exist, just that it is not currently available, but it (or may not) become available in the future.
Therefore, if you can only continue if the module is available, use ensure_compiled!/1 instead. In particular, do not do this:

case Code.ensure_compiled(module) do
  {:module, _} -> module
  {:error, _} -> raise ...
end

What do you think about using ensure_compiled! instead?

The [docs for ensure_compiled](https://hexdocs.pm/elixir/1.13/Code.html#ensure_compiled/1) specifically warn against doing this. To quote:

> If the module being checked is currently in a compiler deadlock, this function returns {:error, :unavailable}. Unavailable doesn't necessarily mean the module doesn't exist, just that it is not currently available, but it (or may not) become available in the future.
Therefore, if you can only continue if the module is available, use ensure_compiled!/1 instead. In particular, do not do this:


```elixir
case Code.ensure_compiled(module) do
  {:module, _} -> module
  {:error, _} -> raise ...
end
```
@msz
Copy link
Owner

msz commented Jun 4, 2022

Nice, thanks! Could you just rebase against latest master so the new workflow passes? I'll then merge it ASAP.

@msz
Copy link
Owner

msz commented Jun 5, 2022

Actually, I just tested the merge locally and this is good to go 👍

@msz msz merged commit 7de8d24 into msz:master Jun 5, 2022
@Adzz
Copy link
Contributor Author

Adzz commented Jun 6, 2022

Apologies just getting to this now! Glad it was okay then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants