Raise errors while computing cache digests - #2712
Merged
joelhawksley merged 9 commits intoSep 22, 2026
Merged
Conversation
erikaxel
force-pushed
the
vc-digest-report-swallowed-errors
branch
from
September 3, 2026 11:55
0c7ba27 to
3f3f1c3
Compare
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
erikaxel
force-pushed
the
vc-digest-report-swallowed-errors
branch
from
September 3, 2026 11:57
3f3f1c3 to
1c1c201
Compare
This was referenced Sep 3, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Match Rails' digest behavior by allowing parser, autoload, dependency tracker, and resolver failures to propagate instead of silently leaving components untracked. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace CacheDigest stubs and private constantization calls with a cacheable component exercised through the public cache_digest API. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use a real cache key method that raises during a normal cached render instead of overriding component internals. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exercise autoload, template dependency tracking, and digest source failures through real components and cache_digest without stubbing ViewComponent internals. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use a dedicated Rails autoload path for failing dependency fixtures instead of inline Ruby autoload declarations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The component digest machinery rescued every unexpected error and returned a neutral value:
CacheDigest::Resolver#find_templatesreturned[]CacheDigest.constantize_componentreturnednilCacheDigest.partial_paths_inreturned[]DependencyTracking#find_dependenciesfell back to Rails' dependenciesA misconfiguration, failed autoload, raising component hook, parser failure, or filesystem error could therefore make a component untracked. Its fragment digest would stop changing and stale HTML could be served with no indication that digest computation had failed.
Rails does not rescue exceptions from dependency tracking or digest-tree construction. It only creates a missing digest node when template lookup normally returns no template.
Fix
Remove the broad rescues and let unexpected digest errors propagate, matching Rails' behavior. Expected missing constants continue to return
nilthroughsafe_constantize, and an ordinary unresolved template continues to use Rails' existing missing-node behavior.Tests
Public
.cache_digestintegration tests use real cacheable components to verify that failures propagate through the complete digest stack:The tests do not stub ViewComponent internals or call private APIs.
Validated locally with:
bundle exec rake all_testsThe full suite completed with 637 Minitests, 5 engine compatibility tests, and 8 RSpec examples, with no failures.