Skip to content

Fix SSR runtime failures for React Server Components#723

Closed
justin808 wants to merge 20 commits into
masterfrom
jg/fix-rsc-ssr-timeout
Closed

Fix SSR runtime failures for React Server Components#723
justin808 wants to merge 20 commits into
masterfrom
jg/fix-rsc-ssr-timeout

Conversation

@justin808

@justin808 justin808 commented Apr 6, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the 37/38 rspec test failures on the RSC branch caused by SSR runtime errors after switching from ExecJS to the react-on-rails-pro NodeRenderer.

  • CI: start Node renderer service — The RSC branch requires the NodeRenderer at port 3800 for SSR, but CI never started it, causing Net::ReadTimeout on all prerendered pages. Added a startup step with TCP readiness check and RENDERER_PASSWORD env var.
  • Server bundle: use fallbacks instead of externals — The previous commit externalized Node builtins (path/fs/stream) as CommonJS require() calls, but the Node renderer's vm.createContext() sandbox has no require. Reverted to resolve.fallback: false which stubs these unused code paths at build time.
  • Server bundle: polyfill MessageChannelreact-dom/server.browser.js instantiates MessageChannel at module load. The Node renderer VM lacks this global (unlike Bun used by ExecJS on master). Added a BannerPlugin polyfill.
  • RouterApp.server.jsx: add 'use client' directive — The auto-bundling system misclassified this traditional SSR component (uses StaticRouter) as a React Server Component because it lacked 'use client'. Added the directive so it registers via ReactOnRails.register() instead of registerServerComponent().

All 38 rspec tests pass locally.

Test plan

  • bundle exec rspec — all 38 tests pass (0 failures)
  • bundle exec rubocop — no offenses
  • All 3 bundles (client, server, RSC) build successfully
  • CI passes on this branch

🤖 Generated with Claude Code


Note

Medium Risk
Touches the SSR/RSC rendering pipeline (NodeRenderer, webpack configs, routing) and upgrades core dependencies, which could break rendering or CI if configuration/env vars are wrong.

Overview
Migrates the app to React on Rails Pro + NodeRenderer for SSR and React Server Components, including a new initializer (react_on_rails_pro.rb) that enables RSC, configures renderer URL/auth, and adds the rsc_payload_route plus a /server-components page.

Adds a third Shakapacker/Rspack build target (rscWebpackConfig.js) and a custom RspackRscPlugin to emit React Flight manifests, updates webpackConfig.js to build client/server/RSC (or select via *_BUNDLE_ONLY), and adjusts SSR bundling to work in the NodeRenderer VM sandbox (CommonJS output, Node-builtin fallbacks, and a MessageChannel polyfill banner).

Updates CI/dev workflow to start and health-check the Node renderer (including RENDERER_PASSWORD), introduces a renderer launcher script + cache ignore, and updates client code to consistently import react-on-rails-pro with added 'use client' directives where needed; includes docs/QA updates and dependency bumps (Rails patch, React/Shakapacker/React on Rails Pro).

Reviewed by Cursor Bugbot for commit 9a71217. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • RSC Demo page added (accessible from navigation) showing server environment, streamed comments with animated skeleton, and interactive toggle panels for selective hydration.
  • Updates
    • Improved server-rendering and React Server Components support for streaming, selective client hydration, and more responsive interactive experiences.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants