Snaps lifecycle
Just like service workers or AWS lambda functions, Snaps are designed to wake up in response to messages/events, and shut down when idle. Snaps have an ephemeral lifecycle: they're here one moment, gone the next. Also, if MetaMask detects that a Snap becomes unresponsive, it shuts the Snap down.
A Snap is considered unresponsive if:
- It hasn't received a JSON-RPC request for 30 seconds.
- It takes more than 60 seconds to process a JSON-RPC request.
Stopped Snaps start whenever they receive a JSON-RPC request, unless they're disabled. If a Snap is disabled, the user must re-enable it before it can start again.