Fix SSR runtime failures for React Server Components#723
Closed
justin808 wants to merge 20 commits into
Closed
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Net::ReadTimeouton all prerendered pages. Added a startup step with TCP readiness check andRENDERER_PASSWORDenv var.path/fs/stream) as CommonJSrequire()calls, but the Node renderer'svm.createContext()sandbox has norequire. Reverted toresolve.fallback: falsewhich stubs these unused code paths at build time.react-dom/server.browser.jsinstantiatesMessageChannelat module load. The Node renderer VM lacks this global (unlike Bun used by ExecJS on master). Added aBannerPluginpolyfill.'use client'directive — The auto-bundling system misclassified this traditional SSR component (usesStaticRouter) as a React Server Component because it lacked'use client'. Added the directive so it registers viaReactOnRails.register()instead ofregisterServerComponent().All 38 rspec tests pass locally.
Test plan
bundle exec rspec— all 38 tests pass (0 failures)bundle exec rubocop— no offenses🤖 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 thersc_payload_routeplus a/server-componentspage.Adds a third Shakapacker/Rspack build target (
rscWebpackConfig.js) and a customRspackRscPluginto emit React Flight manifests, updateswebpackConfig.jsto 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 aMessageChannelpolyfill 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 importreact-on-rails-prowith 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