touchpoints
touchpoints copied to clipboard
Fix: Make Rust widget renderer optional to prevent Sidekiq worker crashes
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.rb for 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.rb was calling Rutie.init unconditionally, which would fail with a Fiddle::DLError when the .so file wasn't present.
Solution
Modified ext/widget_renderer/lib/widget_renderer.rb to only call Rutie.init when 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:
- The
Form#touchpoints_js_stringmethod already has a fallback to ERB rendering when WidgetRenderer is unavailable - Sidekiq doesn't need the WidgetRenderer - it's only used by the web controller for serving form widgets
Testing
- ✅ Deployed to staging Sidekiq worker - now running successfully
- ✅ Staging web app still has WidgetRenderer available (library found in release directory)
Changes
-
ext/widget_renderer/lib/widget_renderer.rb: Added conditional check before callingRutie.init