You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1c1c201
Browse filesBrowse the repository at this point in the historyBrowse files
Report the errors swallowed while computing a cache digest
Every rescue in the digest machinery returns a neutral value, so a
misconfiguration, an autoload failure, or a raising `inherited` hook
degrades to "no component dependencies" and the application serves
stale HTML with nothing reported anywhere.
- Route the four swallow sites through CacheDigest.handle_error
- Log at `warn` through ActiveSupport's logger, preserving the production
guarantee that a stale fragment beats a failed render
- Raise instead in local environments, configurable with
config.view_component.raise_on_cache_digest_errors
Copy file name to clipboardExpand all lines: docs/CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ nav_order: 6
10
10
11
11
## main
12
12
13
+
* Report the errors swallowed while computing a component's cache digest, instead of degrading to an untracked component with no indication that anything went wrong. Digest errors are now raised in local environments and logged at `warn` elsewhere, configurable with `config.view_component.raise_on_cache_digest_errors`.
14
+
15
+
*Erik Axel Nielsen*
16
+
13
17
## 4.15.0
14
18
15
19
* Add experimental caching support, opt-in per component via `include ViewComponent::ExperimentallyCacheable`.
Copy file name to clipboardExpand all lines: docs/guide/caching.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,6 +189,22 @@ The same works in a template, where the branch is often the more natural place f
189
189
190
190
Declared components must include `ViewComponent::ExperimentallyCacheable` themselves, since a component that hasn't opted in has no digest to depend on.
191
191
192
+
## When a digest can't be computed
193
+
194
+
Computing a digest touches the autoloader, the filesystem, and Action View's dependency trackers, any of which can fail. In production those failures are swallowed: a component that can't be digested is left untracked, which is exactly the behavior it had before opting in, and a stale fragment beats a failed render.
195
+
196
+
That trade is wrong while developing, where an untracked component is indistinguishable from a component that was never cached in the first place. Digest failures are therefore raised in local environments and logged at `warn` everywhere else:
197
+
198
+
```console
199
+
[ViewComponent] Ignored an error while resolving PostComponent: NoMethodError: ...
200
+
```
201
+
202
+
To swallow them locally too, or to raise them in production:
0 commit comments