Skip to content

Conversation

justin808
Copy link
Member

@justin808 justin808 commented Sep 29, 2025

Summary

This PR implements the first phase of the React on Rails incremental improvements plan: Better Error Messages with actionable solutions. It transforms generic error messages into intelligent, contextual guides that help developers quickly resolve issues.

Key Changes

1. Smart Error System

  • New SmartError class provides contextual, actionable error messages
  • Pattern-based error detection for common issues (window/document not defined, hydration mismatches)
  • Prioritizes auto-bundling as the recommended approach (no manual registration needed!)
  • Suggests similar component names when typos are detected

2. Enhanced Developer Experience

  • Auto-bundling promoted as primary solution - simpler than manual registration
  • Debug mode for component registration with timing and size metrics
  • Colored output for better readability
  • Clear directory structure visualization in errors

3. JavaScript Debug Capabilities

ReactOnRails.setOptions({ debugMode: true, logComponentRegistration: true });
  • Shows component registration timing
  • Displays component sizes
  • Warns about server/client mismatches

Example of Improvement

Before:

Component HelloWorld not found 

After:

❌ React on Rails Error: Component 'HelloWorld' Not Registered 🚀 Recommended: Use Auto-Bundling (No Registration Required!) 1. Enable auto-bundling in your view: <%= react_component("HelloWorld", props: {}, auto_load_bundle: true) %> 2. Place your component in: app/javascript/components/HelloWorld/HelloWorld.jsx 3. Generate the bundle: bundle exec rake react_on_rails:generate_packs ✨ That's it! No manual registration needed. 

Benefits

  • Faster debugging: Errors provide exact steps to fix issues
  • Simpler development: Auto-bundling eliminates registration boilerplate
  • Better DX: Clear, actionable guidance at every error
  • Performance insights: Debug mode reveals registration bottlenecks

Testing

  • Added comprehensive test suite for SmartError class
  • JavaScript tests for debug logging functionality
  • All changes are backward compatible

Documentation

  • Added comprehensive guide: docs/guides/improved-error-messages.md
  • Includes auto-bundling configuration and best practices
  • Debug mode usage examples

Impact

  • Effort: Low (2-3 days)
  • Impact: High (immediate DX improvement)
  • Breaking Changes: None

🤖 Generated with Claude Code


This change is Reviewable

Summary by CodeRabbit

  • New Features

    • Enhanced, colorized error messages with contextual guidance, suggested fixes, and troubleshooting for server-rendering and registration issues.
    • Optional debug mode and component-registration logging with timing, size hints, and summaries.
  • Documentation

    • New guide on improved error messages, debugging, and auto-bundling.
    • New incremental roadmap outlining phased improvements, metrics, and migration aids.
  • Tests

    • Ruby specs validating smart error scenarios.
    • JavaScript tests covering debug logging, timing, and option handling.
  • Demo

    • Added a demo script showcasing the improved error outputs.
Major improvements to developer experience through enhanced error messages: - Add SmartError class with contextual, actionable error messages - Prioritize auto-bundling (no registration required) in component errors - Include component name suggestions for typos - Enhanced prerender errors with pattern-based troubleshooting - Add debug mode for component registration logging - Show registration timing and component sizes in debug mode - Improve error formatting with colored output - Add comprehensive documentation for new error features Key benefits: - Developers see exact steps to fix issues - Auto-bundling promoted as primary solution (simpler than manual registration) - Reduced debugging time with contextual solutions - Better visibility into component registration process 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

Walkthrough

Adds a SmartError class and integrates it into helper error handling, enhances PrerenderError with context-aware troubleshooting, introduces JS debug options and component-registration logging, updates TypeScript types, adds tests and a demo, and supplies docs and a multi-phase improvement roadmap.

Changes

Cohort / File(s) Summary
Ruby: SmartError & tests + demo
lib/react_on_rails/smart_error.rb, spec/react_on_rails/smart_error_spec.rb, demo_improved_errors.rb
New ReactOnRails::SmartError class producing structured, colorized, context-aware error messages; public readers and solution dispatch; comprehensive RSpec coverage and a demo script showing multiple error scenarios.
Ruby: Prerender error improvements
lib/react_on_rails/prerender_error.rb
Reworked server prerender error formatting with colored header, conditional console section, props/js code blocks, and new build_troubleshooting_suggestions helper for targeted troubleshooting steps.
Ruby: Helper integration
lib/react_on_rails/helper.rb
Replaces plain error raise with ReactOnRails::SmartError for missing auto-loaded bundles; adds require for smart_error and supplies structured payload when raising.
JS client + types
node_package/src/ReactOnRails.client.ts, node_package/src/types/index.ts
Adds debugMode and logComponentRegistration options, updates setOptions to apply/remove them, and conditionally logs/times component registration; TypeScript typings updated.
JS tests
node_package/tests/debugLogging.test.js
New Jest tests covering console logging behavior, debugMode output, component registration timing, and setOptions interactions.
Docs & roadmap
docs/guides/improved-error-messages.md, IMPROVEMENT_SUMMARY.md, REACT_ON_RAILS_IMPROVEMENTS.md
New guide documenting improved error messages and debug features; large incremental improvements roadmap detailing phased initiatives, examples, and success metrics.

Sequence Diagram(s)

sequenceDiagram autonumber participant App as Rails App participant Helper as ReactOnRails::Helper participant SmartErr as ReactOnRails::SmartError participant Prerender as ReactOnRails::PrerenderError App->>Helper: render_react_component(...) alt Autoloaded bundle missing Helper-->>SmartErr: instantiate(error_type: :missing_auto_loaded_bundle, ...) SmartErr-->>App: raise SmartError (formatted guidance) else Server prerender error Helper->>Prerender: format_error(component_name, err, props, js_code, console) Prerender-->>App: raise PrerenderError (detailed troubleshooting) end note over SmartErr,Prerender: Errors include colored headers, context blocks, and troubleshooting suggestions. 
Loading
sequenceDiagram autonumber participant Dev as Developer participant ROR as ReactOnRails (client) participant Console as Console Dev->>ROR: setOptions({ debugMode, logComponentRegistration }) ROR-->>Console: "debugMode/logComponentRegistration enabled" (when true) Dev->>ROR: register(ComponentName, factory) alt debugMode or logComponentRegistration enabled ROR->>Console: "Registering: ComponentName" + size/timing hints ROR->>Console: "Registration complete" else ROR-->>Dev: silent registration end 
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Judahmeek
  • Romex91
  • alexeyr-ci
  • AbanoubGhadban

Poem

A rabbit hops through code and logs,
With tiny paws it clears the fogs.
Smart tips bloom where errors lay,
Console carrots light the way.
Hop on, devs—fixes spring like spring, 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “feat: Add smart error messages with actionable solutions” accurately and concisely summarizes the primary enhancement introduced by the pull request—namely the addition of enriched, context-aware error messaging with guided solutions—without extraneous detail. It clearly conveys the main change to teammates scanning the PR history and aligns with the conventional commit style used in the project.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch better-error-messages

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 and usage tips.

Copy link

claude bot commented Sep 29, 2025

PR Review: Smart Error Messages with Actionable Solutions

Thank you for this excellent PR! The addition of smart error messages is a significant improvement to the React on Rails developer experience. Here's my comprehensive review:

🎯 Overall Assessment

Rating: 9/10 - This is a high-quality implementation that will greatly improve developer experience with minimal breaking changes.

✅ Strengths

1. Excellent Developer Experience Focus

  • The new error messages provide clear, actionable solutions that will reduce debugging time significantly
  • Promoting auto-bundling as the primary solution is a smart move that simplifies the setup process
  • The use of emojis and colored output enhances readability without being overwhelming

2. Well-Structured Implementation

  • The SmartError class is well-designed with clear separation of concerns
  • Error types are clearly defined and consistently handled
  • Good use of pattern matching for different error scenarios

3. Comprehensive Test Coverage

  • Both Ruby and JavaScript sides have appropriate test coverage
  • Tests validate the actual error messages and solutions
  • Debug mode testing includes performance metrics

4. Backwards Compatibility

  • All changes are additive with no breaking changes
  • Debug mode is opt-in with sensible defaults
  • Existing error handling continues to work

🔍 Code Quality Observations

Positive Aspects:

  • Clean separation between error detection and solution generation
  • Good use of Rainbow gem for colored output
  • TypeScript types properly updated for new options
  • Follows existing code patterns and conventions

Minor Suggestions for Improvement:

  1. Consider extracting long string templates: The error message templates in SmartError could be moved to separate methods or a template system for better maintainability.

  2. Add configuration for error verbosity: Consider adding a config option to control error message detail level (compact vs. full).

  3. Performance consideration: The component size calculation in JavaScript (component.toString().length) might be expensive for large components. Consider making this optional or using a more efficient method.

🐛 Potential Issues

1. Ruby Version Compatibility

The code uses some Ruby 3.0+ syntax patterns. Ensure compatibility with the minimum Ruby version specified in the gemspec.

2. Missing Dependency Check

The Rainbow gem is used but should be verified as a dependency in the gemspec file.

3. Edge Case Handling

Consider handling the case where available_components is nil or empty in the fuzzy matching logic.

📝 Documentation Quality

Excellent:

  • Comprehensive guide in docs/guides/improved-error-messages.md
  • Clear examples for each error type
  • Good explanation of auto-bundling benefits

Could Be Enhanced:

  • Add migration guide for existing projects to adopt auto-bundling
  • Include troubleshooting section for common issues
  • Add performance impact notes for debug mode

🔒 Security Considerations

✅ No security concerns identified. Error messages appropriately avoid exposing sensitive information.

🚀 Performance Impact

  • Production: Zero impact (debug features are development-only)
  • Development: Minimal overhead, with optional debug logging
  • Build time: No impact on build performance

💡 Suggestions for Future Enhancements

  1. Error Recovery Suggestions: Add automated fix commands where possible (e.g., auto-run generate_packs)
  2. Error Analytics: Consider adding anonymous error telemetry to understand common pain points
  3. IDE Integration: Provide error message format that IDEs can parse for quick-fix actions
  4. Localization: Consider i18n support for error messages in the future

✨ Highlights

  • The priority on auto-bundling is excellent and aligns with modern developer expectations
  • The error message format strikes a great balance between detail and clarity
  • The implementation is production-ready and will immediately benefit users

📋 Checklist

  • Code follows CLAUDE.md conventions
  • Tests are comprehensive and passing
  • Documentation is clear and complete
  • Backwards compatibility maintained
  • No security vulnerabilities introduced
  • Performance impact is acceptable

🎉 Conclusion

This PR represents a significant improvement to React on Rails and successfully achieves its goals of providing better error messages with actionable solutions. The implementation is thoughtful, well-tested, and maintains backward compatibility while pushing users toward better practices (auto-bundling).

Recommendation: APPROVE

The PR is ready to merge after addressing the minor suggestions above. Great work on this improvement - it will make React on Rails much more developer-friendly!


Review generated with assistance from Claude Code

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
docs/guides/improved-error-messages.md (1)

44-53: Add language hint to the code fence

markdownlint (MD040) is flagging these undecorated fences. Annotate them with a language (e.g., ```text, ```bash, ```erb) so the linter passes and readers get proper syntax highlighting. Apply the same treatment to the other bare fences in this guide.

lib/react_on_rails/prerender_error.rb (1)

50-144: Consider truncating huge console sections

The new troubleshooting blocks are great, but they pull full console_messages into the Ruby exception. For noisy SSR logs this can explode size and overwhelm logs/honeybadger. Maybe trim with Utils.smart_trim or cap at a few KB (similar to props/js code). Worth a follow-up so the message stays readable.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04f3d35 and 96d462a.

📒 Files selected for processing (11)
  • IMPROVEMENT_SUMMARY.md (1 hunks)
  • REACT_ON_RAILS_IMPROVEMENTS.md (1 hunks)
  • demo_improved_errors.rb (1 hunks)
  • docs/guides/improved-error-messages.md (1 hunks)
  • lib/react_on_rails/helper.rb (2 hunks)
  • lib/react_on_rails/prerender_error.rb (2 hunks)
  • lib/react_on_rails/smart_error.rb (1 hunks)
  • node_package/src/ReactOnRails.client.ts (2 hunks)
  • node_package/src/types/index.ts (1 hunks)
  • node_package/tests/debugLogging.test.js (1 hunks)
  • spec/react_on_rails/smart_error_spec.rb (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
{Gemfile,Rakefile,**/*.{rb,rake,gemspec,ru,js,jsx,ts,tsx,json,yml,yaml,md,css,scss}}

📄 CodeRabbit inference engine (CLAUDE.md)

Ensure all committed files end with a trailing newline character

Files:

  • node_package/src/types/index.ts
  • node_package/src/ReactOnRails.client.ts
  • REACT_ON_RAILS_IMPROVEMENTS.md
  • node_package/tests/debugLogging.test.js
  • spec/react_on_rails/smart_error_spec.rb
  • demo_improved_errors.rb
  • lib/react_on_rails/helper.rb
  • docs/guides/improved-error-messages.md
  • lib/react_on_rails/prerender_error.rb
  • lib/react_on_rails/smart_error.rb
  • IMPROVEMENT_SUMMARY.md
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use ESLint for JavaScript/TypeScript and fix all linter offenses before committing

Files:

  • node_package/src/types/index.ts
  • node_package/src/ReactOnRails.client.ts
  • node_package/tests/debugLogging.test.js
**/*.{js,jsx,ts,tsx,json,yml,yaml,md,css,scss}

📄 CodeRabbit inference engine (CLAUDE.md)

Let Prettier handle all non-Ruby file formatting; never manually format these files

Files:

  • node_package/src/types/index.ts
  • node_package/src/ReactOnRails.client.ts
  • REACT_ON_RAILS_IMPROVEMENTS.md
  • node_package/tests/debugLogging.test.js
  • docs/guides/improved-error-messages.md
  • IMPROVEMENT_SUMMARY.md
{Gemfile,Rakefile,**/*.{rb,rake,gemspec,ru}}

📄 CodeRabbit inference engine (CLAUDE.md)

{Gemfile,Rakefile,**/*.{rb,rake,gemspec,ru}}: Before every commit/push, run bundle exec rubocop and fix all violations in Ruby code
Let RuboCop handle all Ruby code formatting; never manually format Ruby files

Files:

  • spec/react_on_rails/smart_error_spec.rb
  • demo_improved_errors.rb
  • lib/react_on_rails/helper.rb
  • lib/react_on_rails/prerender_error.rb
  • lib/react_on_rails/smart_error.rb
🧠 Learnings (7)
📓 Common learnings
Learnt from: alexeyr-ci PR: shakacode/react_on_rails#1644 File: node_package/src/ReactOnRailsRSC.ts:87-87 Timestamp: 2024-12-12T13:07:09.929Z Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging. 
📚 Learning: 2024-12-12T13:07:09.929Z
Learnt from: alexeyr-ci PR: shakacode/react_on_rails#1644 File: node_package/src/ReactOnRailsRSC.ts:87-87 Timestamp: 2024-12-12T13:07:09.929Z Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging. 

Applied to files:

  • node_package/src/types/index.ts
  • node_package/src/ReactOnRails.client.ts
  • node_package/tests/debugLogging.test.js
  • spec/react_on_rails/smart_error_spec.rb
  • demo_improved_errors.rb
  • lib/react_on_rails/helper.rb
  • docs/guides/improved-error-messages.md
  • lib/react_on_rails/prerender_error.rb
  • lib/react_on_rails/smart_error.rb
  • IMPROVEMENT_SUMMARY.md
📚 Learning: 2025-09-15T21:24:48.207Z
Learnt from: AbanoubGhadban PR: shakacode/react_on_rails#1781 File: node_package/src/ClientSideRenderer.ts:82-95 Timestamp: 2025-09-15T21:24:48.207Z Learning: In React on Rails, the force_load feature includes both explicit `data-force-load="true"` usage and the ability to hydrate components during the page loading state (`document.readyState === 'loading'`). Both capabilities require a Pro license, so the condition `!railsContext.rorPro && (isComponentForceLoaded || document.readyState === 'loading')` correctly gates both scenarios. 

Applied to files:

  • node_package/src/types/index.ts
  • node_package/src/ReactOnRails.client.ts
📚 Learning: 2025-02-13T16:50:26.861Z
Learnt from: AbanoubGhadban PR: shakacode/react_on_rails#1644 File: node_package/src/turbolinksUtils.ts:34-36 Timestamp: 2025-02-13T16:50:26.861Z Learning: In React on Rails, when checking for Turbolinks version 5 using `turbolinksVersion5()`, always ensure `Turbolinks` exists first by checking `turbolinksInstalled()` to prevent TypeError when accessing properties. 

Applied to files:

  • node_package/src/types/index.ts
  • lib/react_on_rails/helper.rb
📚 Learning: 2025-04-26T21:55:55.874Z
Learnt from: alexeyr-ci2 PR: shakacode/react_on_rails#1732 File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44 Timestamp: 2025-04-26T21:55:55.874Z Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime. 

Applied to files:

  • REACT_ON_RAILS_IMPROVEMENTS.md
  • lib/react_on_rails/helper.rb
📚 Learning: 2025-09-16T08:01:11.146Z
Learnt from: justin808 PR: shakacode/react_on_rails#1770 File: lib/generators/react_on_rails/templates/base/base/app/javascript/src/HelloWorld/ror_components/HelloWorld.client.jsx:2-2 Timestamp: 2025-09-16T08:01:11.146Z Learning: React on Rails uses webpack CSS Modules configuration with namedExports: true, which requires the import syntax `import * as style from './file.module.css'` rather than the default export pattern. This configuration enables better tree shaking and bundle size optimization for CSS modules. 

Applied to files:

  • lib/react_on_rails/helper.rb
📚 Learning: 2025-04-09T12:56:10.756Z
Learnt from: AbanoubGhadban PR: shakacode/react_on_rails#1696 File: node_package/src/RSCPayloadContainer.ts:0-0 Timestamp: 2025-04-09T12:56:10.756Z Learning: In the react_on_rails codebase, RSC payloads are already stringified using `JSON.stringify()` before being processed by the `escapeScript` function, which handles escaping of special characters. The function only needs to handle specific HTML markers like comments and closing script tags. 

Applied to files:

  • lib/react_on_rails/helper.rb
🧬 Code graph analysis (5)
node_package/src/ReactOnRails.client.ts (2)
node_package/src/pro/ComponentRegistry.ts (1)
  • components (61-61)
node_package/src/types/index.ts (1)
  • ReactComponentOrRenderFunction (178-178)
node_package/tests/debugLogging.test.js (1)
node_package/src/types/index.ts (1)
  • ReactOnRails (281-349)
spec/react_on_rails/smart_error_spec.rb (1)
lib/react_on_rails/smart_error.rb (1)
  • solution (36-53)
lib/react_on_rails/prerender_error.rb (1)
lib/react_on_rails/utils.rb (2)
  • smart_trim (277-291)
  • default_troubleshooting_section (315-323)
lib/react_on_rails/smart_error.rb (3)
lib/react_on_rails/prerender_error.rb (2)
  • attr_reader (7-145)
  • initialize (14-25)
lib/react_on_rails/react_component/render_options.rb (1)
  • auto_load_bundle (78-80)
lib/react_on_rails/utils.rb (1)
  • default_troubleshooting_section (315-323)
🪛 ESLint
node_package/src/ReactOnRails.client.ts

[error] 42-42: Replace ``[ReactOnRails]·Registering·${componentNames.length}·component(s):·${componentNames.join(',·')}); with `⏎········`[ReactOnRails]·Registering·${componentNames.length}·component(s):·${componentNames.join(',·')}`,`

(prettier/prettier)


[error] 43-43: Insert );⏎

(prettier/prettier)


[error] 45-45: Delete ······

(prettier/prettier)


[error] 48-48: Delete ······

(prettier/prettier)


[error] 51-51: Replace name with (name)

(prettier/prettier)

node_package/tests/debugLogging.test.js

[error] 4-4: 'ReactOnRails' is assigned a value but never used.

(no-unused-vars)


[error] 11-11: Delete ····

(prettier/prettier)


[error] 44-44: Unexpected require().

(global-require)


[error] 55-55: Delete ······

(prettier/prettier)


[error] 56-56: 'globalThis' is not defined.

(no-undef)


[error] 57-57: Delete ······

(prettier/prettier)


[error] 64-64: Delete ······

(prettier/prettier)


[error] 65-65: 'globalThis' is not defined.

(no-undef)


[error] 66-66: 'globalThis' is not defined.

(no-undef)


[error] 67-67: Delete ······

(prettier/prettier)


[error] 69-69: Replace log with (log)

(prettier/prettier)


[error] 70-70: Replace log with (log)

(prettier/prettier)


[error] 71-71: Replace (log with ((log)

(prettier/prettier)


[error] 72-72: Replace log with (log)

(prettier/prettier)


[error] 77-77: Delete ······

(prettier/prettier)


[error] 78-78: 'globalThis' is not defined.

(no-undef)


[error] 79-79: 'globalThis' is not defined.

(no-undef)


[error] 80-80: Delete ······

(prettier/prettier)


[error] 82-82: Replace log with (log)

(prettier/prettier)


[error] 83-83: Replace log with (log)

(prettier/prettier)


[error] 90-90: Delete ······

(prettier/prettier)


[error] 91-91: 'globalThis' is not defined.

(no-undef)


[error] 92-92: 'globalThis' is not defined.

(no-undef)


[error] 93-93: Delete ······

(prettier/prettier)


[error] 94-94: Replace log with (log)

(prettier/prettier)


[error] 103-103: 'globalThis' is not defined.

(no-undef)


[error] 105-105: Delete ······

(prettier/prettier)


[error] 106-106: 'globalThis' is not defined.

(no-undef)


[error] 111-111: 'globalThis' is not defined.

(no-undef)


[error] 113-113: Delete ······

(prettier/prettier)


[error] 114-114: 'globalThis' is not defined.

(no-undef)


[error] 118-118: 'globalThis' is not defined.

(no-undef)


[error] 118-118: Delete ·

(prettier/prettier)


[error] 120-120: Replace · with ,

(prettier/prettier)


[error] 122-122: Delete ······

(prettier/prettier)


[error] 123-123: 'globalThis' is not defined.

(no-undef)


[error] 124-124: 'globalThis' is not defined.

(no-undef)


[error] 128-128: 'globalThis' is not defined.

(no-undef)


[error] 130-130: Delete ······

(prettier/prettier)


[error] 132-132: 'globalThis' is not defined.

(no-undef)


[error] 136-136: Insert

(prettier/prettier)

🪛 GitHub Actions: JS unit tests for Renderer package
node_package/src/ReactOnRails.client.ts

[error] 239-239: TypeError: ClientStartup.clientStartup is not a function.

node_package/tests/debugLogging.test.js

[error] 44-44: Test failed in debugLogging.test.js: TypeError: ClientStartup.clientStartup is not a function.

🪛 markdownlint-cli2 (0.18.1)
REACT_ON_RAILS_IMPROVEMENTS.md

25-25: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


96-96: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


193-193: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


291-291: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


383-383: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


493-493: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


608-608: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


703-703: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/guides/improved-error-messages.md

44-44: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


104-104: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


119-119: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


124-124: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


174-174: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


179-179: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


200-200: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


221-221: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


349-349: Bare URL used

(MD034, no-bare-urls)


350-350: Bare URL used

(MD034, no-bare-urls)


351-351: Bare URL used

(MD034, no-bare-urls)


352-352: Bare URL used

(MD034, no-bare-urls)

IMPROVEMENT_SUMMARY.md

80-80: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


85-85: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: markdown-link-check
  • GitHub Check: claude-review
  • GitHub Check: rspec-package-tests (3.2, latest)
  • GitHub Check: rspec-package-tests (3.4, latest)
  • GitHub Check: rspec-package-tests (3.2, minimum)
  • GitHub Check: rspec-package-tests (3.4, minimum)
  • GitHub Check: build-and-test
🔇 Additional comments (2)
lib/react_on_rails/helper.rb (1)

798-803: Clarify SmartError migration path

Thanks for switching the missing auto-loaded bundle check to the new SmartError flow. A follow-up note: anywhere else we were rescuing ReactOnRails::Error from this code path should be reviewed because the concrete type has now changed. If you already swept callers/tests, feel free to ignore. Otherwise, consider a quick search so those handlers keep working.

spec/react_on_rails/smart_error_spec.rb (1)

106-127: Solid coverage of solution pathways.

The parameterized check ensures every error type gets a non-empty, string solution response—nice way to safeguard future regressions.

- Fix performance API compatibility with polyfill - Add missing clientStartup mock in tests - Replace globalThis with window in test file - Use async import instead of require - Add language hints to markdown code blocks - Ensure files end with newline character
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96d462a and 9364784.

📒 Files selected for processing (5)
  • IMPROVEMENT_SUMMARY.md (1 hunks)
  • REACT_ON_RAILS_IMPROVEMENTS.md (1 hunks)
  • docs/guides/improved-error-messages.md (1 hunks)
  • node_package/src/ReactOnRails.client.ts (2 hunks)
  • node_package/tests/debugLogging.test.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • node_package/src/ReactOnRails.client.ts
🧰 Additional context used
📓 Path-based instructions (3)
{Gemfile,Rakefile,**/*.{rb,rake,gemspec,ru,js,jsx,ts,tsx,json,yml,yaml,md,css,scss}}

📄 CodeRabbit inference engine (CLAUDE.md)

Ensure all committed files end with a trailing newline character

Files:

  • IMPROVEMENT_SUMMARY.md
  • docs/guides/improved-error-messages.md
  • REACT_ON_RAILS_IMPROVEMENTS.md
  • node_package/tests/debugLogging.test.js
**/*.{js,jsx,ts,tsx,json,yml,yaml,md,css,scss}

📄 CodeRabbit inference engine (CLAUDE.md)

Let Prettier handle all non-Ruby file formatting; never manually format these files

Files:

  • IMPROVEMENT_SUMMARY.md
  • docs/guides/improved-error-messages.md
  • REACT_ON_RAILS_IMPROVEMENTS.md
  • node_package/tests/debugLogging.test.js
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use ESLint for JavaScript/TypeScript and fix all linter offenses before committing

Files:

  • node_package/tests/debugLogging.test.js
🧠 Learnings (5)
📓 Common learnings
Learnt from: alexeyr-ci PR: shakacode/react_on_rails#1644 File: node_package/src/ReactOnRailsRSC.ts:87-87 Timestamp: 2024-12-12T13:07:09.929Z Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging. 
📚 Learning: 2024-12-12T13:07:09.929Z
Learnt from: alexeyr-ci PR: shakacode/react_on_rails#1644 File: node_package/src/ReactOnRailsRSC.ts:87-87 Timestamp: 2024-12-12T13:07:09.929Z Learning: When handling errors in 'node_package/src/ReactOnRailsRSC.ts', include the error stack in error messages in development and test environments to aid debugging. 

Applied to files:

  • IMPROVEMENT_SUMMARY.md
  • docs/guides/improved-error-messages.md
  • node_package/tests/debugLogging.test.js
📚 Learning: 2025-04-26T21:55:55.874Z
Learnt from: alexeyr-ci2 PR: shakacode/react_on_rails#1732 File: spec/dummy/client/app-react16/startup/ReduxSharedStoreApp.client.jsx:40-44 Timestamp: 2025-04-26T21:55:55.874Z Learning: In the react_on_rails project, files under `app-react16` directories are copied/moved to corresponding `/app` directories during the conversion process (removing the `-react16` suffix), which affects their relative import paths at runtime. 

Applied to files:

  • REACT_ON_RAILS_IMPROVEMENTS.md
📚 Learning: 2024-10-08T20:53:47.076Z
Learnt from: theforestvn88 PR: shakacode/react_on_rails#1620 File: spec/dummy/client/app/startup/HelloTurboStream.jsx:3-3 Timestamp: 2024-10-08T20:53:47.076Z Learning: The `RailsContext` import in `spec/dummy/client/app/startup/HelloTurboStream.jsx` is used later in the project, as clarified by the user theforestvn88. 

Applied to files:

  • node_package/tests/debugLogging.test.js
📚 Learning: 2025-07-08T05:57:29.630Z
Learnt from: AbanoubGhadban PR: shakacode/react_on_rails#1745 File: node_package/src/RSCRequestTracker.ts:8-14 Timestamp: 2025-07-08T05:57:29.630Z Learning: The global `generateRSCPayload` function in React on Rails Pro (RORP) is provided by the framework during rendering requests, not implemented in application code. The `declare global` statements are used to document the expected interface that RORP will inject at runtime. 

Applied to files:

  • node_package/tests/debugLogging.test.js
🪛 markdownlint-cli2 (0.18.1)
docs/guides/improved-error-messages.md

29-29: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


107-107: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


211-211: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


316-316: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🪛 GitHub Actions: JS unit tests for Renderer package
node_package/tests/debugLogging.test.js

[error] 44-44: Test failed in debugLogging.test.js due to ReactOnRails overwrite protection error observed in ReactOnRails.client.ts.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: dummy-app-integration-tests (3.2, 20)
  • GitHub Check: dummy-app-integration-tests (3.4, 22)
  • GitHub Check: markdown-link-check
  • GitHub Check: rspec-package-tests (3.2, latest)
  • GitHub Check: rspec-package-tests (3.2, minimum)
  • GitHub Check: rspec-package-tests (3.4, latest)
  • GitHub Check: rspec-package-tests (3.4, minimum)
  • GitHub Check: claude-review
  • GitHub Check: build-and-test
Comment on lines +43 to +45
// Import ReactOnRails after mocking using dynamic import
await import('../src/ReactOnRails.client.ts');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Reset the global ReactOnRails handle between tests

ReactOnRails.client.ts guards against being loaded twice; because beforeEach dynamically re-imports the module without clearing window.ReactOnRails, the second import raises the overwrite-protection error that is currently failing CI. Please delete (and optionally restore) the global before re-importing so every test starts from a clean slate.

Apply this diff to isolate each test run:

@@ - // Mock console.log to capture output + // Mock console.log to capture output consoleOutput = []; originalConsoleLog = console.log; console.log = jest.fn((...args) => { consoleOutput.push(args.join(' ')); }); + // Ensure ReactOnRails can reinitialize safely + delete window.ReactOnRails; @@ afterEach(() => { console.log = originalConsoleLog; + delete window.ReactOnRails; jest.clearAllMocks(); });

Also applies to: 48-50

🧰 Tools
🪛 GitHub Actions: JS unit tests for Renderer package

[error] 44-44: Test failed in debugLogging.test.js due to ReactOnRails overwrite protection error observed in ReactOnRails.client.ts.

🤖 Prompt for AI Agents
In node_package/tests/debugLogging.test.js around lines 43-45 (and also 48-50), the test re-imports ../src/ReactOnRails.client.ts without clearing the global window.ReactOnRails, causing the module's overwrite-protection to throw on repeated loads; before each dynamic import remove window.ReactOnRails (e.g., delete window.ReactOnRails) and after the test optionally restore any previous value if needed so each test starts with a clean global and the dynamic import won't trigger the guard. 
Deleted demo file that was causing RuboCop violations in CI. The demo content has been incorporated into proper documentation and implementation files. Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant