Fix: Make Rust widget renderer optional to prevent Sidekiq worker crashes#1909
Open
rileyseaburg wants to merge 1 commit intodevelopfrom
Open
Fix: Make Rust widget renderer optional to prevent Sidekiq worker crashes#1909rileyseaburg wants to merge 1 commit intodevelopfrom
rileyseaburg wants to merge 1 commit intodevelopfrom
Conversation
….so missing The widget_renderer.rb was unconditionally calling Rutie.init even when the native library wasn't found, causing a Fiddle::DLError crash. This broke the Sidekiq worker in production (170+ crashes) since it doesn't have the Rust buildpack but still loads Rails initializers. Now the code only attempts to load Rutie when the library file exists, and gracefully falls back to ERB rendering otherwise.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes the Rust widget renderer optional to prevent Sidekiq worker processes from crashing when the native library is unavailable. The solution conditionally initializes the Rutie extension only when the library file is found, with appropriate error handling and logging.
Key Changes:
- Modified
widget_renderer.rbto wrap Rutie initialization in a conditional check based on whether the native library was found - Added rescue block to catch
Fiddle::DLErrorexceptions during library loading - Added informative logging for both success and failure scenarios
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 Sidekiq worker was crashing on startup with
Fiddle::DLError: libwidget_renderer.so: cannot open shared object file.This occurred because the Rails initializer loads
widget_renderer.rbfor ALL processes (including Sidekiq), but the Sidekiq worker deployment doesn't include the Rust buildpack, so the native library doesn't exist.Root Cause
widget_renderer.rbwas callingRutie.initunconditionally, which would fail with aFiddle::DLErrorwhen the.sofile wasn't present.Solution
Modified
ext/widget_renderer/lib/widget_renderer.rbto only callRutie.initwhen the library file is actually found. If the library isn't present, it logs a warning and the WidgetRenderer class simply won't be available.This is safe because:
Form#touchpoints_js_stringmethod already has a fallback to ERB rendering when WidgetRenderer is unavailableTesting
Changes
ext/widget_renderer/lib/widget_renderer.rb: Added conditional check before callingRutie.init