touchpoints icon indicating copy to clipboard operation
touchpoints copied to clipboard

Fix: Make Rust widget renderer optional to prevent Sidekiq worker crashes

Open rileyseaburg opened this issue 1 month ago • 0 comments

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:

  1. The Form#touchpoints_js_string method already has a fallback to ERB rendering when WidgetRenderer is unavailable
  2. 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 calling Rutie.init

rileyseaburg avatar Dec 03 '25 21:12 rileyseaburg