Repository navigation
Recompile components compiled inside with_new_cache - #2735
Merged
joelhawksley merged 2 commits intoOct 22, 2026
Merged
Conversation
Components compiled in the block keep the settings they were compiled under, such as coverage stripping the BEGIN annotation, but the restored cache still listed them as compiled. The template annotations integration test then failed whenever it ran after the coverage compile tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.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.
What are you trying to accomplish?
IntegrationTest#test_rendering_component_with_template_annotations_enabledfails for some test orders. It failed the Rails 8.1 job on #2734 with seed 6880, and the same seed fails onmain(18619ae):To reproduce:
bundle exec rake test TESTOPTS="--seed=6880".What approach did you choose and why?
InlineTemplateTest's "file-based templates compile without segfault when coverage is running" recompilesErbComponentinsidewith_new_cachewhileCoverageis running. Under coverage,Template::File#compiled_sourcestrips theBEGINannotation line on purpose. When the block ends,with_new_cacherestores the previous cache, which still listsErbComponentas compiled, so the stripped methods stay on the class. If the integration test runs later, it renders those methods and theBEGINannotation is missing. The "annotations disabled" variant leavesErbComponentcompiled without annotations in the same way.with_new_cachenow removes the components compiled inside the block from the restored cache, so they compile again under the normal settings the next time they render. This fixes the helper rather than the two tests, because any test that compiles a component insidewith_new_cacheunder temporary settings can leak them the same way.Anything you want to highlight for special attention from reviewers?
The only cost is that those components compile once more after the block. Locally the full suite passes with seed 6880 and seeds 42, 1234 and 777 on Rails 8.1.2 and 8.1.4, and standardrb is clean. With seeds 1, 9999 and 31337,
ViewComponentSystemTest#test_layout_is_not_nestedtimed out in headless Chrome on my machine. Seed 1 times out the same way onmainwithout this change, so it looks local rather than related.This came up on #2734, whose Rails 8.1 job failed with seed 6880.
🤖 Generated with Claude Code