Fix SKIP_WIDGET_RENDERER to work at gem load time#1936
Merged
rileyseaburg merged 1 commit intoproductionfrom Dec 23, 2025
Merged
Fix SKIP_WIDGET_RENDERER to work at gem load time#1936rileyseaburg merged 1 commit intoproductionfrom
rileyseaburg merged 1 commit intoproductionfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR moves the SKIP_WIDGET_RENDERER environment variable check to the beginning of widget_renderer.rb to fix a production crash where the native library loading fails before the initializer can run. When the env var is set to 'true', a stub class is provided instead of attempting to load the native library.
Key Changes
- Early environment variable check before requiring dependencies
- Stub class implementation when renderer should be skipped
- Addition of
available?method to both stub and native implementations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def self.render_widget(template, data) | ||
| # Return nil to signal caller should use ERB fallback | ||
| nil | ||
| end |
There was a problem hiding this comment.
The stub implementation defines render_widget(template, data) but the actual usage in the codebase calls WidgetRenderer.generate_js(json). The stub should define generate_js to match the actual interface of the native implementation.
Suggested change
| end | |
| end | |
| def self.generate_js(json) | |
| # Return nil to signal caller should use JS/ERB fallback | |
| nil | |
| end |
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.
Summary
SKIP_WIDGET_RENDERERcheck to the beginning ofwidget_renderer.rbso it runs duringBundler.requireSKIP_WIDGET_RENDERER=true, provides a stub class with the same interface instead of crashingRoot Cause
The previous fix added the env var to manifests, but the check was in an initializer that runs after
Bundler.requireinconfig/application.rb. The gem was crashing during the bundle require phase before the initializer could run.