-
- Notifications
You must be signed in to change notification settings - Fork 638
feat: Add smart error messages with actionable solutions #1834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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>
WalkthroughAdds 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
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. 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 Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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. Comment |
PR Review: Smart Error Messages with Actionable SolutionsThank 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 AssessmentRating: 9/10 - This is a high-quality implementation that will greatly improve developer experience with minimal breaking changes. ✅ Strengths1. Excellent Developer Experience Focus
2. Well-Structured Implementation
3. Comprehensive Test Coverage
4. Backwards Compatibility
🔍 Code Quality ObservationsPositive Aspects:
Minor Suggestions for Improvement:
🐛 Potential Issues1. Ruby Version CompatibilityThe code uses some Ruby 3.0+ syntax patterns. Ensure compatibility with the minimum Ruby version specified in the gemspec. 2. Missing Dependency CheckThe Rainbow gem is used but should be verified as a dependency in the gemspec file. 3. Edge Case HandlingConsider handling the case where available_components is nil or empty in the fuzzy matching logic. 📝 Documentation QualityExcellent:
Could Be Enhanced:
🔒 Security Considerations✅ No security concerns identified. Error messages appropriately avoid exposing sensitive information. 🚀 Performance Impact
💡 Suggestions for Future Enhancements
✨ Highlights
📋 Checklist
🎉 ConclusionThis 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 |
There was a problem hiding this 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 fencemarkdownlint (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 sectionsThe 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 withUtils.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
📒 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, runbundle 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 pathThanks for switching the missing auto-loaded bundle check to the new
SmartError
flow. A follow-up note: anywhere else we were rescuingReactOnRails::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
There was a problem hiding this 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
📒 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
// Import ReactOnRails after mocking using dynamic import | ||
await import('../src/ReactOnRails.client.ts'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
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
SmartError
class provides contextual, actionable error messages2. Enhanced Developer Experience
3. JavaScript Debug Capabilities
Example of Improvement
Before:
After:
Benefits
Testing
Documentation
docs/guides/improved-error-messages.md
Impact
🤖 Generated with Claude Code
This change is
Summary by CodeRabbit
New Features
Documentation
Tests
Demo