-
-
Notifications
You must be signed in to change notification settings - Fork 636
Fix missing return statement in removeRSCChunkStack test utility #2242
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: upcoming-partial-prerender-feature
Are you sure you want to change the base?
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
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 |
Code Review FeedbackSummaryThis PR fixes a critical bug in the ✅ What's Good1. Critical Bug Fix
2. TypeScript Should Have Caught This
🔍 Code QualityPositive:
|
size-limit report 📦
|
Code Review - PR #2242SummaryThis PR fixes a critical bug where ✅ Strengths
|
Code ReviewSummaryThis PR fixes a critical bug in the AnalysisThe Bug: const removeRSCChunkStack = (chunk: string) => {
chunk.split('\n').map(removeRSCChunkStackInternal).join('\n'); // ❌ Missing return
};The Fix: const removeRSCChunkStack = (chunk: string) => {
return chunk.split('\n').map(removeRSCChunkStackInternal).join('\n'); // ✅ Now returns the result
};ImpactThis function is used in:
Without this fix, the function would return
Positive Feedback✅ Clean, minimal fix - Changes only what's necessary Recommendations1. Add/Update Tests (Required)The PR checklist mentions "Add/update test to cover these changes" - you should: // Consider adding a unit test for removeRSCChunkStack
describe('removeRSCChunkStack', () => {
it('should return transformed chunk, not undefined', () => {
const input = '1:{"stack":"error stack"}\n2:{"data":"value"}';
const result = removeRSCChunkStack(input);
expect(result).toBeDefined();
expect(result).not.toContain('"stack"');
});
});This would have caught the bug during development. 2. Update PR Description (Required)Your PR body still has placeholder text. Please update it with:
3. Update CHANGELOG (Required - if user-facing)Since this is a Pro package bug fix that could affect functionality, add an entry to #### Bug Fixes
- [PR 2242](https://github.com/shakacode/react_on_rails/pull/2242) by [AbanoubGhadban](https://github.com/AbanoubGhadban): Fixed `removeRSCChunkStack` utility function not returning transformed resultHowever, if this is purely test infrastructure and doesn't affect end users, you can skip the CHANGELOG per the project guidelines. Code Quality: Excellent ✨The fix itself is perfect - it's exactly what's needed, nothing more, nothing less. Great catch on finding this bug! Security & Performance: No ConcernsNo security issues or performance implications from this change. Overall Assessment: LGTM with minor documentation updates needed 🚀 The code change is correct and necessary. Just needs the PR description filled out and consideration of whether a CHANGELOG entry is needed (depends on whether this affects end users or just test infrastructure). |
The existing test in concurrentRSCPayloadGeneration.rsc.test.tsx compared removeRSCChunkStack(chunk) === removeRSCChunkStack(nextChunk), which passed even when the function returned undefined (since undefined === undefined is true). This new test directly verifies that removeRSCChunkStack returns a defined string value, which would fail if the return statement is missing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review - PR #2242SummaryThis PR fixes a critical bug in the ✅ Strengths
|
Summary
Fixes a missing
returnstatement in theremoveRSCChunkStacktest utility function and adds a regression test.The Bug
The
removeRSCChunkStackfunction was missing areturnstatement:How It Was Discovered
This bug was discovered during code review. The function was returning
undefinedinstead of the processed string.Why Existing Tests Didn't Catch It
The test at line 90 of
concurrentRSCPayloadGeneration.rsc.test.tsxcompares:Since the buggy function returned
undefinedfor both calls, the comparisonundefined === undefinedevaluated totrue, causing the test to pass incorrectly.Regression Test Added
Added
removeRSCChunkStack.test.tswith direct unit tests that:undefined)Verified locally:
returnstatement (TypeScript error:voidnot assignable tostring)Changelog Entry
Not needed - this is a test utility function that is:
Test Plan
pnpm exec jest tests/removeRSCChunkStack.test.ts- passes with fixreturnstatementpnpm run test:rsc- all RSC tests pass