Skip to content

Reduce Rspack RSC dev-server manifest footgun#4234

Merged
justin808 merged 7 commits into
mainfrom
jg-codex/rsc-rspack-footgun-followup
Jun 27, 2026
Merged

Reduce Rspack RSC dev-server manifest footgun#4234
justin808 merged 7 commits into
mainfrom
jg-codex/rsc-rspack-footgun-followup

Conversation

@justin808

@justin808 justin808 commented Jun 27, 2026

Copy link
Copy Markdown
Member

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 Reduce Rspack RSC dev-server manifest footgun #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

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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

RSC generator docs and specs now resolve rscWebpackConfig.js from the active bundler directory. Rspack development config generation disables client lazy compilation when RSC is present, and Doctor adds a Rspack-specific empty-manifest warning with matching troubleshooting guidance.

Changes

RSC generator and Rspack diagnostics

Layer / File(s) Summary
Bundler-relative discovery path
react_on_rails/lib/generators/react_on_rails/rsc_setup/client_references.rb, docs/oss/api-reference/generator-details.md, docs/pro/installation.md, react_on_rails/lib/generators/react_on_rails/rsc/USAGE, react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb, react_on_rails/spec/react_on_rails/generators/rsc_generator_spec.rb
rscWebpackConfig.js is resolved from the active bundler directory, and the generator docs and specs describe the webpack and rspack discovery paths.
Rspack dev config and generator output
react_on_rails/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt, react_on_rails/spec/react_on_rails/generators/install_generator_spec.rb
development.js.tt now takes rscWebpackConfig and disables clientWebpackConfig.lazyCompilation when it is present, with generator specs updated to match the new Rspack config shape.
Rspack doctor warning and docs
react_on_rails/lib/react_on_rails/doctor.rb, react_on_rails/spec/lib/react_on_rails/doctor_spec.rb, docs/oss/migrating/rsc-troubleshooting.md, CHANGELOG.md
ReactOnRails::Doctor adds a Rspack lazy-compilation check to check_rsc_setup, and the troubleshooting docs and changelog describe the empty-manifest symptom and message mapping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Suggested labels

bug, full-ci, P2

Suggested reviewers

  • AbanoubGhadban
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately reflects the main change: reducing a Rspack RSC dev-server manifest issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg-codex/rsc-rspack-footgun-followup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR reduces an Rspack RSC dev-server manifest footgun. The main changes are:

  • Disables lazy compilation in generated Rspack dev-server config when RSC config is present.
  • Looks for rscWebpackConfig.js in the active generated config directory.
  • Adds RSC doctor diagnostics for existing Rspack apps.
  • Documents the empty React Client Manifest troubleshooting path.

Confidence Score: 4/5

The RSC doctor diagnostic can report success for configs that still leave the RSC client bundle lazy.

  • The generator changes follow the intended Rspack/RSC path.
  • The new doctor check can miss the existing-app failure it is meant to detect.
  • The observable result is an empty React Client Manifest in normal bin/dev with no doctor warning.

react_on_rails/lib/react_on_rails/doctor.rb

Important Files Changed

Filename Overview
react_on_rails/lib/react_on_rails/doctor.rb Adds the Rspack RSC lazy-compilation diagnostic, but the success check can match unrelated lazy-compilation settings.
react_on_rails/lib/generators/react_on_rails/rsc_setup/client_references.rb Updates generated client-reference discovery to look beside the active config file.
react_on_rails/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt Updates generated dev config to receive rscWebpackConfig and disable Rspack lazy compilation when present.

Reviews (1): Last reviewed commit: "Reduce Rspack RSC dev-server manifest fo..." | Re-trigger Greptile

Comment thread react_on_rails/lib/react_on_rails/doctor.rb Outdated
Comment thread react_on_rails/lib/react_on_rails/doctor.rb
@justin808

Copy link
Copy Markdown
Member Author

+ci-run-hosted

Comment thread react_on_rails/lib/react_on_rails/doctor.rb
@github-actions github-actions Bot added the ready-for-hosted-ci Run optimized hosted GitHub CI for this PR label Jun 27, 2026
Comment thread react_on_rails/spec/lib/react_on_rails/doctor_spec.rb
@github-actions

Copy link
Copy Markdown
Contributor

Hosted CI Requested

Triggered 9 workflow(s) for 73cc567c4e7a.
Mode: optimized hosted CI (path-selected by script/ci-changes-detector).
Added ready-for-hosted-ci, so future commits will keep running optimized hosted CI until +ci-stop-hosted is used.

View progress in the Actions tab.

@claude

claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review: Reduce Rspack RSC dev-server manifest footgun

Overall this is a solid, well-scoped follow-up. The two core code changes are correct:

  • client_references.rb: replacing the hardcoded 'config/webpack/rscWebpackConfig.js' with resolve(__dirname, 'rscWebpackConfig.js') is the right fix — it makes discovery work from whatever directory the file actually lives in (webpack or rspack).
  • development.js.tt: removing the fs/path imports and switching from a filesystem existence check to the parameter already provided by ServerClientOrBoth.js.tt is cleaner and more semantically correct. The template was already passing rscConfig as the third argument when use_rsc? is true, so this change is safe.

Three things worth addressing before merge:

1. Regex can false-positive on commented-out code (doctor.rb, lines 3525–3528)

RSC_RSPACK_LAZY_COMPILATION_DISABLED_PATTERN will match // clientWebpackConfig.lazyCompilation = false; inside a comment and report success. This could silently mislead users who commented out the guard during debugging. Stripping //-prefixed lines before matching eliminates the most common case. See inline comment.

2. Success message is overconfident (doctor.rb, line 3636)

"✅ Rspack lazy compilation disabled for RSC dev-server" is asserted whenever the pattern appears anywhere in the file — including outside the WEBPACK_SERVE or rscWebpackConfig guards. Labelling it as a heuristic check would set correct expectations. See inline comment.

3. Missing test for the "dev config not found" branch (doctor_spec.rb, lines 5289–5299)

The around block always writes config/rspack/development.js, so the early-return path that fires when the file is absent is uncovered. One additional test case would close that gap. See inline comment.

Everything else — changelog, USAGE, docs, generator test updates — looks good and is consistent with the changes.

@claude

claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review — Reduce Rspack RSC dev-server manifest footgun

This PR makes three targeted improvements: it replaces the fragile filesystem probe in development.js.tt with a parameter-passed rscWebpackConfig arg, fixes rscConfigSupportsDiscovery to look sibling-relative rather than hardcoded to config/webpack/, and adds a doctor:rsc check for the lazy-compilation footgun. The approach is clean and the test coverage is solid for the happy/sad paths.

Two confirmed issues with the new regex in check_rsc_rspack_lazy_compilation, and one missing test case worth noting.

1. Regex produces false success on commented-out guards

RSC_RSPACK_LAZY_COMPILATION_DISABLED_PATTERN is matched against raw file content without stripping JS comments. A developer who leaves the old guard commented out triggers the pattern and gets ✅ while lazy compilation is actually still enabled. Example: // clientWebpackConfig.lazyCompilation = false; — the // characters are non-word, so \b\w+ still anchors on clientWebpackConfig and the match succeeds.

2. Regex matches the wrong config variable

The first alternative (\b\w+WebpackConfig) is broad enough that serverWebpackConfig.lazyCompilation = false or rscWebpackConfig.lazyCompilation = false both match. Neither of those settings prevents the RSC client manifest from being empty, but the check reports success anyway.

A minimal fix addressing both: strip comment lines and pin the LHS to clientWebpackConfig:

RSC_RSPACK_LAZY_COMPILATION_DISABLED_PATTERN = /
  ^[^\/\n]*\bclientWebpackConfig\.lazyCompilation\s*=\s*false\b |
  ^[^\/\n]*\blazyCompilation\s*:\s*false\b
/x

3. Silent skip when rscWebpackConfig.js is absent has no test (minor)

When active_assets_bundler == "rspack" but config/rspack/rscWebpackConfig.js doesn't exist yet, the method returns with no output at all. The spec's around block always creates that file, so this branch is never exercised. A partial-setup user running the doctor sees nothing from this check while the footgun is still live.

Comment thread react_on_rails/lib/react_on_rails/doctor.rb
Comment thread react_on_rails/spec/lib/react_on_rails/doctor_spec.rb

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@react_on_rails/lib/react_on_rails/doctor.rb`:
- Around line 3525-3528: The lazyCompilation detector in the doctor regex is
matching commented-out examples, so it can incorrectly report success from
non-executable text. Update the logic around
RSC_RSPACK_LAZY_COMPILATION_DISABLED_PATTERN so it ignores comments before
testing, or replace the raw-text regex with a parser-aware check that only
recognizes actual code assignments in the relevant doctor check.
- Around line 3624-3646: The Rspack lazy-compilation check in
check_rsc_rspack_lazy_compilation is hardcoded to the default config/rspack
path, so it can miss apps using a custom assets_bundler_config_path. Update the
check to resolve both the RSC webpack config and the development config from the
active bundler directory/path used by active_assets_bundler instead of fixed
config/rspack filenames. Keep the existing warning/success behavior, but ensure
File.exist? and File.read operate on the bundler-relative paths so the check
works for non-default layouts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 84c3f1f1-2839-47d5-bdbe-89428c8e58ea

📥 Commits

Reviewing files that changed from the base of the PR and between 84f1350 and bc4cbd9.

📒 Files selected for processing (11)
  • CHANGELOG.md
  • docs/oss/api-reference/generator-details.md
  • docs/oss/migrating/rsc-troubleshooting.md
  • docs/pro/installation.md
  • react_on_rails/lib/generators/react_on_rails/rsc/USAGE
  • react_on_rails/lib/generators/react_on_rails/rsc_setup/client_references.rb
  • react_on_rails/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt
  • react_on_rails/lib/react_on_rails/doctor.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

Comment thread react_on_rails/lib/react_on_rails/doctor.rb Outdated
Comment thread react_on_rails/lib/react_on_rails/doctor.rb

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
react_on_rails/lib/react_on_rails/doctor.rb (2)

3624-3628: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Resolve the Rspack files from the active bundler config directory.

This still hardcodes config/rspack/rscWebpackConfig.js and config/rspack/development.js, so apps using a non-default assets_bundler_config_path will silently skip the warning even though the same empty-manifest footgun applies. Derive both paths from the active bundler directory instead of assuming the default layout. Based on the PR objectives and stack context, RSC config discovery in this change set is meant to be bundler-relative.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@react_on_rails/lib/react_on_rails/doctor.rb` around lines 3624 - 3628, The
Rspack/RSC config check in doctor.rb is still tied to hardcoded config/rspack
paths, so it misses apps using a custom assets_bundler_config_path. Update the
RSC config discovery logic around the active_assets_bundler == "rspack" guard to
derive both the RSC webpack config and development config paths from the active
bundler config directory instead of fixed defaults, and keep the warning in
checker.add_warning tied to those resolved paths.

3525-3526: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Ignore comments before matching the lazyCompilation assignment.

This detector still runs on raw file text, so // clientWebpackConfig.lazyCompilation = false (or a commented example in docs/config) will report success even though lazy compilation is still enabled. Strip comments first or make the check parser-aware before applying this pattern. Based on the existing review history, this is the same still-unresolved false-positive path previously flagged.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@react_on_rails/lib/react_on_rails/doctor.rb` around lines 3525 - 3526, The
lazyCompilation detector still matches commented text, so the
RSC_RSPACK_CLIENT_LAZY_COMPILATION_DISABLED_PATTERN in doctor.rb can report a
false success on raw file text. Update the detection logic around this pattern
to ignore comments first or make it parser-aware before evaluating
clientWebpackConfig.lazyCompilation = false, so only real assignments are
treated as disabling lazy compilation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@react_on_rails/lib/react_on_rails/doctor.rb`:
- Around line 3624-3628: The Rspack/RSC config check in doctor.rb is still tied
to hardcoded config/rspack paths, so it misses apps using a custom
assets_bundler_config_path. Update the RSC config discovery logic around the
active_assets_bundler == "rspack" guard to derive both the RSC webpack config
and development config paths from the active bundler config directory instead of
fixed defaults, and keep the warning in checker.add_warning tied to those
resolved paths.
- Around line 3525-3526: The lazyCompilation detector still matches commented
text, so the RSC_RSPACK_CLIENT_LAZY_COMPILATION_DISABLED_PATTERN in doctor.rb
can report a false success on raw file text. Update the detection logic around
this pattern to ignore comments first or make it parser-aware before evaluating
clientWebpackConfig.lazyCompilation = false, so only real assignments are
treated as disabling lazy compilation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a462daa7-1fd3-4165-a191-fafa25beacee

📥 Commits

Reviewing files that changed from the base of the PR and between bc4cbd9 and 73cc567.

📒 Files selected for processing (2)
  • react_on_rails/lib/react_on_rails/doctor.rb
  • react_on_rails/spec/lib/react_on_rails/doctor_spec.rb
🚧 Files skipped from review as they are similar to previous changes (1)
  • react_on_rails/spec/lib/react_on_rails/doctor_spec.rb

@claude

claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Code Review — PR #4234: Reduce Rspack RSC dev-server manifest footgun

This PR follows up #4227 by making Rspack RSC dev-server setup more discoverable: it fixes the client-reference discovery path to be __dirname-relative (correct for Rspack apps), shifts the lazy-compilation guard from a filesystem check to a parameter check, and adds a doctor:rsc check plus troubleshooting documentation. The changes are well-targeted and the test coverage is solid.

Two confirmed issues with the new doctor check deserve attention, plus one gap in the migration guide.

Finding 1 — Doctor reports false success when the fix line is commented out

The regex RSC_RSPACK_CLIENT_LAZY_COMPILATION_DISABLED_PATTERN is pure text-matching against the raw file string. A line like // clientWebpackConfig.lazyCompilation = false; matches the pattern (the word boundary fires after the space following //), so the doctor reports a success even though the assignment is dead code. The manifest remains empty with no warning.

Suggested fix: strip single-line JS comments before matching: development_config.gsub(%r{//[^\n]*}, '').match?(pattern)

Finding 2 — Pattern matches the assignment regardless of which branch it appears in

The doctor hint says to add the line inside the Rspack WEBPACK_SERVE branch, but the regex matches anywhere in the file. clientWebpackConfig.lazyCompilation = false appearing in a production-only block or outside the WEBPACK_SERVE guard generates a false-positive success while lazyCompilation remains enabled during dev-server mode.

A practical minimum: require WEBPACK_SERVE to also appear in the file before reporting success, or add a comment on the constant noting the check is intentionally approximate.

Finding 3 — Troubleshooting guide omits the ServerClientOrBoth.js prerequisite

The new section instructs existing Rspack RSC users to update config/rspack/development.js with the if (rscWebpackConfig) guard. But rscWebpackConfig is only non-undefined if ServerClientOrBoth.js calls envSpecific(clientConfig, serverConfig, rscConfig) with 3 arguments. Projects that set up RSC via the generator already have this; users with manually assembled configs or a partial migration may have the 2-arg call, making the new guard silently inert. The guide should note that ServerClientOrBoth.js must also pass rscConfig as the third argument, or recommend re-running the RSC generator to refresh both files.

Comment thread react_on_rails/lib/react_on_rails/doctor.rb
Comment thread react_on_rails/lib/react_on_rails/doctor.rb
Comment thread docs/oss/migrating/rsc-troubleshooting.md
@justin808

Copy link
Copy Markdown
Member Author

Address-review summary

Scan scope: full PR history through 2026-06-27T08:13:34Z.

Mattered

  • Fixed commented-line and unrelated-config false positives in eb667e0; doctor now checks clientWebpackConfig.lazyCompilation = false and specs cover commented-out, server, and RSC config variants.
  • Fixed missing doctor coverage in eb667e0 for absent development.js, absent rscWebpackConfig.js, and custom Shakapacker Rspack config directories.
  • Fixed the troubleshooting guide prerequisite in 6ceecb0; docs now mention ServerClientOrBoth.js must pass rscConfig as the third envSpecific argument.

Optional

  • Auto-deferred exact JavaScript branch parsing for the doctor heuristic; replied with [auto-deferred] rationale and kept the lighter text scan plus "appears disabled" success wording.

Skipped

  • Duplicate bot summaries/status comments only; no separate follow-up needed.

Next default scan starts after this comment. Say check all reviews to rescan the full PR.

@claude

claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Code review findings for PR 4234 (posting in parts due to shell escaping constraints).

@claude

claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Code Review: PR 4234 - Three findings

  1. Pro dummy ServerClientOrBoth.js never passes rscConfig to envSpecific (bug): react_on_rails_pro/spec/dummy/config/webpack/ServerClientOrBoth.js line 26 calls envSpecific(clientConfig, serverConfig) with only 2 args even though rscConfig is computed on line 23. The new development.js.tt uses 'if (rscWebpackConfig)' to gate lazyCompilation=false, so since rscWebpackConfig is always undefined in the dummy, lazy compilation is never disabled. Fix: envSpecific(clientConfig, serverConfig, rscConfig).

  2. Doctor hint 'rerun the RSC generator' does not fix development.js (misleading): update_webpack_configs_for_rsc in rsc_setup.rb touches ServerClientOrBoth.js, serverWebpackConfig.js, and clientWebpackConfig.js but never development.js. A user following the hint will retain the old 2-arg developmentEnvOnly and the warning persists. The hint should point to the manual edit in the troubleshooting guide, or the generator should patch development.js.

  3. CHANGELOG order (minor): The Fixed section uses descending PR-number order (4231, 4227, 4213...). PR 4234 is placed below PR 4227 rather than above it.

Comment thread react_on_rails/lib/react_on_rails/doctor.rb
Comment thread react_on_rails/lib/react_on_rails/doctor.rb
Comment thread CHANGELOG.md Outdated
@justin808

Copy link
Copy Markdown
Member Author

Addressed the in-scope items from #4234 (comment):

  • 138d70a fixes the doctor hint so it points to the manual troubleshooting guide instead of saying the RSC generator updates development.js.
  • 138d70a moves the PR 4234 changelog entry above older PR numbers.
  • I verified the Pro dummy note against the tree: react_on_rails_pro/spec/dummy/config/webpack/ServerClientOrBoth.js is a webpack fixture, so the Rspack lazy-compilation guard added here does not make that Pro file a blocker for this PR. Per the repo boundary, I did not edit react_on_rails_pro/ without explicit Pro-scope approval.

@justin808

Copy link
Copy Markdown
Member Author

Address-review summary

Scan scope: review activity after 2026-06-27T08:14:22Z.

Mattered

  • Fixed the doctor hint in 138d70a; it now points to the manual Rspack RSC troubleshooting section.
  • Fixed changelog ordering in 138d70a; PR 4234 now appears above older PR numbers.
  • Verified the Pro dummy comment as not a blocker for this Rspack PR and left react_on_rails_pro/ untouched per repo boundary.

Optional

  • Auto-deferred removing the local doctor rescue; replied with [auto-deferred] rationale because the specific path-oriented warning is useful and changing error routing is broader than this follow-up.

Skipped

  • Duplicate/status comments only.

Next default scan starts after this comment. Say check all reviews to rescan the full PR.

@claude

claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review: Reduce Rspack RSC dev-server manifest footgun

This PR is a solid follow-up to #4227. The generator fix (switching from a filesystem existsSync check to receiving rscWebpackConfig as a parameter), the doctor diagnostic, and the troubleshooting docs are all well-structured and the test coverage is thorough. Two things worth a second look:


1. Doctor regex accepts unconditional placement as success

RSC_RSPACK_CLIENT_LAZY_COMPILATION_DISABLED_PATTERN scans the entire file — it matches clientWebpackConfig.lazyCompilation = false; regardless of whether it is inside the WEBPACK_SERVE guard. The doctor's own hint says "Add this inside the Rspack WEBPACK_SERVE branch", but a bare unconditional assignment at the top level of development.js also reports ✅ Rspack lazy compilation appears disabled. This is low severity (unconditional placement is functionally fine for RSC correctness), but the guidance and the check are slightly inconsistent.

The test fixture at line 5331 in doctor_spec.rb writes the bare assignment (no guard) and expects success — so this is deliberate, but it means the hint in the warning message overstates the constraint.


2. Parameter-based guard silently breaks for manually-added RSC configs

The old development.js.tt used existsSync(resolve(__dirname, 'rscWebpackConfig.js')) — a self-contained runtime check that activated automatically whenever rscWebpackConfig.js was present, regardless of how developmentEnvOnly was called. The new template relies entirely on the rscWebpackConfig parameter, which is only non-null when ServerClientOrBoth.js was generated with use_rsc? = true.

Edge case: a developer who manually drops rscWebpackConfig.js into their config directory (following a tutorial or copying from a sample app) without re-running rails g react_on_rails:rsc will find that the new development.js silently does not disable lazy compilation — because ServerClientOrBoth.js was never regenerated with the RSC argument. The old code would have caught this automatically. The troubleshooting doc and doctor check partially mitigate this, but the behavioral regression for the manual-setup path is worth noting in a migration note or generator log message.


No blocking issues. Both items are low-to-medium severity and well within the context of a diagnostic/DX improvement PR.

Comment thread react_on_rails/lib/react_on_rails/doctor.rb
@claude

claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Code Review

This PR follows up on #4227 with three related fixes: (1) switching the dev-server lazy-compilation guard from a filesystem existsSync check to a parameter-based check, (2) making the RSC client-reference discovery helper look up rscWebpackConfig.js relative to __dirname instead of hardcoding config/webpack/, and (3) adding a react_on_rails:doctor:rsc check that warns existing Rspack RSC apps when their dev config doesn't disable lazy compilation. The direction is correct and the new doctor check is well-tested.


Bug: Pro dummy ServerClientOrBoth.js computes rscConfig but drops it — lazy compilation fix is silent there

react_on_rails_pro/spec/dummy/config/webpack/ServerClientOrBoth.js, line 26

envSpecific(clientConfig, serverConfig);   // ← rscConfig computed on line 23 but never forwarded

The generator template (ServerClientOrBoth.js.tt) was updated so that RSC-enabled apps pass envSpecific(clientConfig, serverConfig, rscConfig). But this already-materialised Pro dummy file was not regenerated. Because the caller only passes 2 arguments, the new rscWebpackConfig parameter in developmentEnvOnly (the change in development.js.tt) will always be undefined in the Pro dummy's dev-server flow, so clientWebpackConfig.lazyCompilation is never set to false. This is the exact symptom the PR targets, still unfixed in the Pro reference app.

Fix: change line 26 to envSpecific(clientConfig, serverConfig, rscConfig);
react_on_rails_pro/spec/dummy/config/webpack/development.js line 22 also needs the rscWebpackConfig third parameter added.


Nit: rsc_rspack_config_directory silently returns nil with no message

react_on_rails/lib/react_on_rails/doctor.rb, check_rsc_rspack_lazy_compilation

When shakapacker_assets_bundler_config_path is nil and none of RSPACK_DEFAULT_CONFIG_CANDIDATES exist on disk, rsc_rspack_config_directory returns nil and the caller does return unless config_directory — producing zero output. An Rspack RSC app with a non-standard config location would silently skip the lazy-compilation check with no hint that anything was missed. A one-liner checker.add_info(" 💡 Could not locate Rspack config directory; skipping lazy-compilation check") before that early return would surface the gap.


Nit: /x regex flag without any inline comments is misleading

react_on_rails/lib/react_on_rails/doctor.rb, RSC_RSPACK_CLIENT_LAZY_COMPILATION_DISABLED_PATTERN

RSC_RSPACK_CLIENT_LAZY_COMPILATION_DISABLED_PATTERN = /
  ^\s*clientWebpackConfig\.lazyCompilation\s*=\s*false\b
/x

The /x (extended) flag exists to allow inline comments inside a regex; used without any comments it only adds visual noise and a latent trap: a future maintainer who adds # only in dev-server branch after the pattern would silently truncate it to /^\s*clientWebpackConfig/ (everything after # is ignored in /x mode). The single-line form is clearer:

RSC_RSPACK_CLIENT_LAZY_COMPILATION_DISABLED_PATTERN =
  /^\s*clientWebpackConfig\.lazyCompilation\s*=\s*false\b/

Comment thread react_on_rails/lib/react_on_rails/doctor.rb
Comment thread react_on_rails/lib/react_on_rails/doctor.rb
@justin808

Copy link
Copy Markdown
Member Author

Replying to #4234 (comment):

[auto-deferred]
For the unconditional clientWebpackConfig.lazyCompilation = false case, keeping the doctor as a lightweight heuristic. Unconditional placement is functionally safe for the RSC dev-server footgun, and the warning still recommends the narrower WEBPACK_SERVE placement for users copying the fix.

[auto-deferred]
For manually-added rscWebpackConfig.js, 6ceecb0 documented the ServerClientOrBoth.js third-argument prerequisite in the troubleshooting section. I am not adding a separate generator log/message in this PR because the intended generated path already passes rscConfig, and this follow-up is primarily doctor/docs guidance for existing apps.

Comment thread docs/oss/migrating/rsc-troubleshooting.md
Comment thread react_on_rails/lib/react_on_rails/doctor.rb
Comment thread react_on_rails/lib/react_on_rails/doctor.rb
@claude

claude Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Code review posted as inline comments. Top-level summary: clean follow-up to 4227, core fixes are correct. Two actionable items flagged inline: (1) troubleshooting doc should lead with the unconditional fix since the conditional form requires ServerClientOrBoth.js to also be updated; (2) rsc_rspack_config_directory silently skips when no rspack config is found at default paths, an info message would help non-standard setups. One informational note on the regex pattern.

@justin808 justin808 added this pull request to the merge queue Jun 27, 2026
Merged via the queue into main with commit c2de1e1 Jun 27, 2026
60 checks passed
@justin808 justin808 deleted the jg-codex/rsc-rspack-footgun-followup branch June 27, 2026 09:07
justin808 added a commit that referenced this pull request Jun 27, 2026
Rebased on main and regenerated llms-full after CI flagged a stale
generated file. Applied reviewer-requested doc fixes, all kept faithful
to the official starter (shakacode/react-on-rails-starter-tanstack),
whose files each carry a REFERENCE PATTERN marker matching the snippets:

- Add an Install section (mirrors the sister TanStack Router guide).
- Fix the "Mistake 5" cross-link to target the section anchor.
- Show apiFetch's real getCsrfToken import and ApiFetchOptions type so
  the snippet stands alone (matches lib/apiFetch.ts).
- Note that the initialData seed carries no initialDataUpdatedAt, so the
  table does one background refetch on mount; document how to opt out.

llms-full-pro.txt picks up one inherited line from #4234 (RSC generator
text) that landed on main without a pro-file regen; the new OSS-only page
does not appear in the pro bundle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-hosted-ci Run optimized hosted GitHub CI for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant