You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Follow-up to #4227 / #4226. The original fix disabled Rspack lazy
compilation for generated RSC apps, but the behavior was still easy for
existing apps to miss and one helper still assumed the RSC config lived
under `config/webpack`.
This PR:
- disables Rspack lazy compilation in generated dev-server config when
an RSC config is present
- makes RSC client-reference discovery check the sibling
`rscWebpackConfig.js` in the active config directory
- adds `react_on_rails:doctor:rsc` diagnostics for existing Rspack RSC
apps whose dev config does not disable lazy compilation
- documents the empty React Client Manifest / `lazy-compilation-proxy` /
`POST /_rspack/lazy/trigger` 404 troubleshooting path
- adds the #4234 changelog entry under Unreleased / Fixed
## Validation
- `cd react_on_rails && bundle exec rspec
spec/react_on_rails/generators/install_generator_spec.rb -e 'disables
Rspack lazy compilation while serving RSC apps' -e 'checks RSC discovery
support in the generated Rspack config directory'`
- `cd react_on_rails && bundle exec rspec
spec/react_on_rails/generators/rsc_generator_spec.rb -e 'when Pro is
installed on an existing rspack project'`
- `cd react_on_rails && bundle exec rspec
spec/react_on_rails/generators/rsc_generator_spec.rb -e 'when an
existing client RSC webpack config already references the scoped
helper'`
- `cd react_on_rails && bundle exec rspec
spec/lib/react_on_rails/doctor_spec.rb -e
'check_rsc_rspack_lazy_compilation' -e 'warns when the Rspack RSC config
supports manifest discovery and the manifest is missing'`
- `bundle exec rubocop react_on_rails/lib/react_on_rails/doctor.rb
react_on_rails/lib/generators/react_on_rails/rsc_setup/client_references.rb
react_on_rails/spec/lib/react_on_rails/doctor_spec.rb
react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
react_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb`
- `pnpm start format.listDifferent`
- `git diff --check origin/main...HEAD`
- `script/ci-changes-detector origin/main`
- `/Users/justin/.agents/skills/autoreview/scripts/autoreview --mode
local` clean before push
- pre-push hook: branch RuboCop plus online Markdown link check passed
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **Bug Fixes**
- Improved RSC dev-server diagnostics for Rspack, with warnings when
client lazy compilation isn’t disabled and it may cause an empty React
Client Manifest.
- Updated diagnostics to verify client-reference discovery using the
correct RSC config location.
- Refined RSC + Rspack setup guidance to ensure the Rspack development
config disables client lazy compilation when RSC is present.
- **Documentation**
- Clarified supported locations for RSC bundler configuration for both
webpack and Rspack.
- Expanded RSC troubleshooting with Rspack-specific “empty client
manifest” symptoms and remediation.
- **Tests**
- Updated generator and doctor specs for the revised Rspack/RSC behavior
and diagnostics.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Copy file name to clipboardExpand all lines: docs/oss/migrating/rsc-troubleshooting.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ When something goes wrong during RSC migration, start here. This table maps symp
20
20
|`ReferenceError: fetch is not defined` (or `Headers`, `Request`, `Response`, `AbortController`, `AbortSignal`) | Node renderer VM context missing fetch globals |[Node Renderer VM Context](#node-renderer-vm-context----missing-globals)|
21
21
|`ReferenceError: require is not defined`| Server bundle or RSC bundle uses `externals` for Node builtins instead of `resolve.fallback`|[Handling Node Builtins](#handling-node-builtins----externals-vs-resolvefallback)|
22
22
|`ReferenceError: MessageChannel is not defined`|`react-dom/server.browser` needs `MessageChannel` at load time in VM sandbox |[MessageChannel Not Defined](#messagechannel-not-defined)|
23
+
| RSC says a module is missing from the React Client Manifest and the manifest is empty in Rspack `bin/dev`| Rspack lazy compilation deferred RSC client references before the server renderer read them |[Empty Client Manifest with Rspack Dev Server](#empty-client-manifest-with-rspack-dev-server)|
23
24
| SSR hangs or times out on large pages | Stream backpressure deadlock |[Stream Backpressure Deadlock](#stream-backpressure-deadlock)|
24
25
| Rails boot error about version mismatch | Gem and npm package at different versions |[Gem and npm Package Version Mismatch](#gem-and-npm-package-version-mismatch)|
25
26
| 422 Unprocessable Entity on form submission | Missing CSRF token in fetch request |[Mutations](rsc-data-fetching.md#mutations-rails-controllers-not-server-actions)|
@@ -774,6 +775,54 @@ class Api::UsersController < ApplicationController
774
775
end
775
776
```
776
777
778
+
## Empty Client Manifest with Rspack Dev Server
779
+
780
+
In RSC apps that use Rspack, normal `bin/dev` dev-server mode must compile RSC client references before the server renderer reads the React Client Manifest. If Rspack lazy compilation is still enabled, the first server render can see an empty manifest and fail with an error like:
781
+
782
+
```text
783
+
Could not find the module ".../LikeButton.jsx#default" in the React Client Manifest.
- the generated Rspack client bundle mentions `lazy-compilation-proxy`
790
+
- the browser sends `POST /_rspack/lazy/trigger` and Rails returns `404`
791
+
-`bin/dev static` works, but normal `bin/dev` fails
792
+
793
+
Run the RSC doctor first:
794
+
795
+
```bash
796
+
bundle exec rails react_on_rails:doctor:rsc
797
+
```
798
+
799
+
For existing generated apps, update `config/rspack/development.js` so the Rspack dev-server branch disables lazy compilation when an RSC config is present:
If it only passes `clientConfig` and `serverConfig`, rerun the RSC generator to refresh both `ServerClientOrBoth.js` and `development.js`.
823
+
824
+
Fresh generator output includes this guard. If your config has been heavily customized, keep the important behavior: RSC + Rspack + dev-server mode should set `clientWebpackConfig.lazyCompilation = false`.
825
+
777
826
## Bundle Analysis Tools
778
827
779
828
| Tool | Purpose |
@@ -810,6 +859,7 @@ end
810
859
|`ReferenceError: require is not defined`| Server or RSC bundle webpack config uses `externals` for Node builtins, generating `require()` calls that fail in VM sandbox | Use `resolve.fallback: { path: false, fs: false }` instead of `externals`. See [Handling Node Builtins](#handling-node-builtins----externals-vs-resolvefallback)|
811
860
|`ReferenceError: MessageChannel is not defined`|`react-dom/server.browser` instantiates `MessageChannel` at module load time; VM sandbox lacks this global | Inject a `BannerPlugin` polyfill in the server webpack config. See [MessageChannel Not Defined](#messagechannel-not-defined)|
812
861
|`"global object mismatch"`|`react-on-rails` and `react-on-rails-pro` resolved from different sources (e.g., npm vs yalc) | Force consistent resolution with `pnpm.overrides` or `yarn.resolutions`. See [Version Mismatch](#version-mismatch----global-object-mismatch)|
862
+
| Missing module in React Client Manifest with empty `filePathToModuleMetadata` in Rspack `bin/dev`| Rspack lazy compilation deferred RSC client references before manifest generation | Disable Rspack lazy compilation for RSC dev-server mode. See [Empty Client Manifest with Rspack Dev Server](#empty-client-manifest-with-rspack-dev-server)|
813
863
| SSR hangs indefinitely / request timeout on large RSC payloads | Stream backpressure deadlock when RSC payload exceeds 16 KB | Update to latest React on Rails Pro. See [Stream Backpressure Deadlock](#stream-backpressure-deadlock)|
814
864
|`"The 'react-on-rails' package version does not match the gem version"`| Gem and npm package installed at different versions | Install the npm package version matching your gem. See [Gem and npm Package Version Mismatch](#gem-and-npm-package-version-mismatch)|
815
865
|`"The 'react-on-rails' package version is not an exact version"`| Using semver ranges (`^`, `~`, `*`) instead of an exact version in package.json | Pin to the exact version without range operators. See [Gem and npm Package Version Mismatch](#gem-and-npm-package-version-mismatch)|
The RSC generator creates `rscWebpackConfig.js`, adds `RSCWebpackPlugin`to both server and client webpack configs, configures `RSC_BUNDLE_ONLY` handling in `ServerClientOrBoth.js`, and sets up the RSC bundle watcher process. See [React Server Components](./react-server-components/tutorial.md) for more information.
94
+
The RSC generator creates `rscWebpackConfig.js` in the active bundler config directory (`config/webpack/` or `config/rspack/`), adds the RSC bundler plugin to both server and client configs, configures `RSC_BUNDLE_ONLY` handling in `ServerClientOrBoth.js`, and sets up the RSC bundle watcher process. See [React Server Components](./react-server-components/tutorial.md) for more information.
0 commit comments