OeditusCredo.Check.Refactoring.AvoidUnawaitedTaskAsync
(OeditusCredo v0.10.2)
View Source
Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of high and works with any version of Elixir.
Explanation
Task.async links the calling process to the task and expects Task.await. Ignoring the task handle can cause unhandled exit signals to crash the calling process if the task fails. Use Task.Supervisor.start_child/2 or Task.start/1 for fire-and-forget tasks.
Bad:
Task.async(fn -> send_email(user) end)Good:
Task.Supervisor.start_child(MyApp.TaskSupervisor, fn -> send_email(user) end)Check-Specific Parameters
There are no specific parameters for this check.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.