docs/oss/building-features/node-renderer/debugging.md
Pro Feature — Available with React on Rails Pro. Free or very low cost for startups and small companies. Upgrade or licensing details →
Because the renderer communicates over a port to the server, you can start a renderer instance locally in your application and debug it.
For renderer debugging inside this repo, use the Pro dummy app at react_on_rails_pro/spec/dummy.
It is a pnpm workspace app and already points at the local packages in this monorepo.
If you already have the dummy app running via bin/dev (which uses Procfile.dev), the node renderer is already listening on port 3800 with --inspect enabled. To debug:
chrome://inspect in Chrome and connect to the renderer process.overmind connect node-renderer (Ctrl-B to detach).overmind restart node-renderer.Use this when you need full control over the renderer process — different flags, a specific bundle, or rebuilding just the renderer package.
pnpm install
pnpm run build
cd react_on_rails_pro/spec/dummy
pnpm run build:dev:watch
cd react_on_rails_pro/spec/dummy
RENDERER_LOG_LEVEL=debug pnpm run node-renderer
cd react_on_rails_pro/spec/dummy
pnpm run node-renderer-debug
packages/react-on-rails-pro-node-renderer, rebuild that package before restarting the renderer:
pnpm --filter react-on-rails-pro-node-renderer run build
yalc, npm pack, or a workspace link) before rerunning the renderer.If worker memory grows over time, use heap snapshots to find the source.
--heapsnapshot-signal (no code changes)Use Node's built-in flag to write heap snapshots on demand:
cd react_on_rails_pro/spec/dummy
# Adjust the port if your Rails app points at a different renderer URL.
NODE_OPTIONS="--heapsnapshot-signal=SIGUSR2" RENDERER_PORT=3800 node client/node-renderer.js
Then capture snapshots at different times:
kill -USR2 <worker-pid> # writes a .heapsnapshot file to the working directory
This also works in production containers — set NODE_OPTIONS="--heapsnapshot-signal=SIGUSR2" as an environment variable, send the signal at different times, then copy the .heapsnapshot files to your local machine for analysis.
For more precise results, start the renderer with --expose-gc and a custom signal handler that forces garbage collection before each snapshot. See the Memory Leaks guide for the code.
.heapsnapshot files in Chrome DevTools (Memory tab → Load).string, Object, and Array counts — these typically point to module-level caches.When diagnosing memory leaks in a containerized environment, running the Node renderer as a separate workload (instead of a sidecar) makes it easier to:
See the Memory Leaks guide for common patterns and fixes.
Open the gemfile in the problematic app.
gem "react_on_rails_pro", path: "../../../shakacode/react-on-rails/react_on_rails_pro"
Optionally, also specify react_on_rails to be local:
gem "react_on_rails", path: "../../../shakacode/react-on-rails/react_on_rails"