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:
- Open
chrome://inspectin Chrome and connect to the renderer process. - Use overmind to isolate renderer logs:
overmind connect node-renderer(Ctrl-B to detach). - After a code change, restart just the renderer:
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.
- From the repo root, install dependencies and build the local packages:
pnpm install pnpm run build
- In one terminal, start the Pro dummy bundle watcher:
cd react_on_rails_pro/spec/dummy pnpm run build:dev:watch - In another terminal, start the renderer with verbose logging:
cd react_on_rails_pro/spec/dummy RENDERER_LOG_LEVEL=debug pnpm run node-renderer - If you want to attach a debugger instead, run:
cd react_on_rails_pro/spec/dummy pnpm run node-renderer-debug - Reload the page that triggers the SSR issue and reproduce the problem.
- If you change Ruby code in loaded gems, restart the Rails server.
- If you change code under
packages/react-on-rails-pro-node-renderer, rebuild that package before restarting the renderer:pnpm --filter react-on-rails-pro-node-renderer run build
- If you are debugging an external app instead of the monorepo dummy app, refresh the installed renderer package using your local package workflow (for example
yalc,npm pack, or a workspace link) before rerunning the renderer.
If worker memory grows over time, use heap snapshots to find the source.
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 renderer/node-renderer.jsThen capture snapshots at different times:
kill -USR2 <worker-pid> # writes a .heapsnapshot file to the working directoryThis 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.
- Load both
.heapsnapshotfiles in Chrome DevTools (Memory tab → Load). - Use the Comparison view to see which objects accumulated between snapshots.
- Look for growing
string,Object, andArraycounts — 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:
- Monitor Node memory independently from Rails
- Capture heap snapshots without affecting the Rails process
- Restart or scale the renderer without restarting Rails
See the Memory Leaks guide for common patterns and fixes.
- See this article on setting up the debugger.
- See the Jest documentation for overall guidance.
- For RubyMine, see the RubyMine documentation for the current information. The original Testing With Jest in WebStorm post can be useful as well.
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"