You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add gem version validation between Ruby gem and Node renderer
Adds validation to ensure the React on Rails Pro gem version matches
the node renderer package version for best compatibility.
**Changes:**
- **Ruby side** (`lib/react_on_rails_pro/utils.rb`):
- Add `railsEnv` to `common_form_data` method to send Rails environment
to the node renderer
- **Node renderer** (`packages/node-renderer/src/worker/checkProtocolVersionHandler.ts`):
- Add gem version validation logic with environment-aware behavior
- Create `normalizeVersion()` function to handle version format differences:
- Ruby gem format: `4.0.0.rc.1` → NPM format: `4.0.0-rc.1`
- Case-insensitive comparison (e.g., `4.0.0-RC.1` == `4.0.0-rc.1`)
- Whitespace trimming
- **Development**: Throw 412 error when versions don't match
- **Production**: Log warning but allow request to proceed
- **Tests** (`packages/node-renderer/tests/worker.test.ts`):
- Update 11 existing tests to include `railsEnv` field
- Add 6 new comprehensive tests for gem version validation:
- Matching versions test
- Development environment mismatch rejection
- Production environment mismatch allowance
- Version normalization tests (dot format, case-insensitive, whitespace)
**Edge cases handled:**
- ✅ Prerelease format differences (4.0.0.rc.1 vs 4.0.0-rc.1)
- ✅ Case sensitivity (4.0.0-RC.1 vs 4.0.0-rc.1)
- ✅ Whitespace trimming
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
constmismatchMessage=`React on Rails Pro gem version (${gemVersion}) does not match node renderer version (${packageJson.version}). Using exact matching versions is recommended for best compatibility.`;
63
+
64
+
if(isProduction){
65
+
// In production, log a warning but allow the request to proceed
66
+
log.warn(mismatchMessage);
67
+
}else{
68
+
// In development, throw an error to prevent potential issues
0 commit comments