No receive Without Timeout

View Source

All receive expressions should be accompanied by an after expressions.

Avoid

receive
    something ->
        do:something()
end

Prefer

receive
    something ->
        do:something()
after 60_000 ->
    exit(nothing_received)
end

Rationale

A receive block without a timeout will wait indefinitely if no matching message arrives; by making your timeout explicit you:

  • avoid hanging processes.
  • improve testability (deterministic behavior under test failure conditions).
  • ease debug and recovery.
  • can implement retry and self-healing.
  • potentially avoid denial-of-service scenarios where waits are exploited.

Options

  • None.

Example configuration

{elvis_style, no_receive_without_timeout, #{}}