# `CredoHotUpgrades.Check.OnLoad`
[🔗](https://github.com/deployex/credo_hot_upgrades/blob/main/lib/credo_hot_upgrades/check/on_load.ex#L1)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `normal` and works with any version of Elixir.

## Explanation

`@on_load` runs once a module's code is loaded and before the module is
available for use. A hot upgrade loads the new version of every module it
touches, so a module already running gets its `on_load` function run a
second time, on the same node, for code that was never cold-started.

Code written assuming `on_load` only ever happens once (seeding a table,
starting a watcher, registering something that cannot be registered
twice) duplicates the work or raises on that second call. Guard it, or do
that work from `Application.start/2` or a supervised process instead,
neither of which a hot upgrade calls again on its own.

## Check-Specific Parameters

*There are no specific parameters for this check.*

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
