OeditusCredo.Check.Refactoring.AvoidUnawaitedTaskAsync (OeditusCredo v0.11.1)

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

Use the following parameters to configure this check:

:exclude_test_files

Set to true to skip test files (default: false)

This parameter defaults to nil.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.