Whether the HTML a component just rendered is safe to keep.
A missing file is a finished answer: the placeholder is what the next request produces too, and a renderer may cache it. A lookup that raised — a column the running code expects but the database does not have yet, a dead connection — is not finished. The placeholder is still what this request shows, and the next request has to try again.
lookup/2 runs the query. take/1 is what a caching renderer wraps the
whole render in: {:ok, html} may be stored, {:retry, html} must not.
The mark lives on the calling process for that take/1. Nested renders
propagate failures to their enclosing render; a later independent render
starts clean. Lookups in tasks or other processes are not tracked.
Summary
Functions
Runs fun. Returns whatever it returns, including nil for a missing file.
If fun raises, or the database call exits (a dead pool exits rather
than raises), records the failure and returns fallback.
@spec lookup_failed() :: :ok
Records that the lookup inside the current take/1 raised.
lookup/2 does this itself. Other code calls it when it has already
rescued the error and still rendered a placeholder.
@spec take((-> result)) :: {:ok | :retry, result} when result: term()
Runs fun and reports whether its result may be cached.
{:ok, result} — no lookup raised.
{:retry, result} — one did. result is still the rendered page
(placeholders included); do not store it.
Nested calls track their own result and propagate failures to the enclosing
call. Cleans up when fun raises, exits or throws as well.