Fix: Make Rust widget renderer optional to prevent Sidekiq worker crashes #1909
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