Skip to content

Commit 68b9399

Browse files
Fix CI lint failures and address review feedback
- Fix prettier formatting in test files - Fix ESLint errors in demo components (unreachable code, line length) - Remove issue references from demo component text - Guard cleanup() against double-ending resultStream by delegating to endResultStream() which has writableEnded check - Use bare `raise` instead of `raise e` to preserve original backtrace Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5b697cb commit 68b9399

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed

packages/react-on-rails-pro-node-renderer/tests/handleStreamError.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ describe('handleStreamError', () => {
2222
source.destroy(new Error('something went wrong during rendering'));
2323

2424
await new Promise((resolve) => setTimeout(resolve, 50));
25-
expect(onError).toHaveBeenCalledWith(expect.objectContaining({ message: 'something went wrong during rendering' }));
25+
expect(onError).toHaveBeenCalledWith(
26+
expect.objectContaining({ message: 'something went wrong during rendering' }),
27+
);
2628

2729
const streamEnded = await Promise.race([
2830
new Promise<'ended'>((resolve) => {

packages/react-on-rails-pro-node-renderer/tests/streamErrorHang.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ describe('streaming render error handling - E2E', () => {
162162
expect(timedOut).toBe(false);
163163

164164
// The error IS reported
165-
expect(errorReporter.message).toHaveBeenCalledWith(
166-
expect.stringContaining('mid-stream rendering error'),
167-
);
165+
expect(errorReporter.message).toHaveBeenCalledWith(expect.stringContaining('mid-stream rendering error'));
168166
}, 10000);
169167

170168
it('HTTP response completes when rendering stream errors before any data', async () => {
@@ -173,9 +171,7 @@ describe('streaming render error handling - E2E', () => {
173171
// The response completes gracefully
174172
expect(timedOut).toBe(false);
175173

176-
expect(errorReporter.message).toHaveBeenCalledWith(
177-
expect.stringContaining('immediate rendering error'),
178-
);
174+
expect(errorReporter.message).toHaveBeenCalledWith(expect.stringContaining('immediate rendering error'));
179175
}, 10000);
180176

181177
it('HTTP response completes normally when stream ends without errors', async () => {

packages/react-on-rails-pro/src/injectRSCPayload.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,7 @@ export default function injectRSCPayload(
326326
*/
327327
htmlStream.on('end', () => {
328328
const cleanup = () => {
329-
if (flushTimeout) {
330-
clearTimeout(flushTimeout);
331-
}
332-
333-
flush();
334-
resultStream.end();
329+
endResultStream();
335330
};
336331

337332
if (!rscPromise) {

react_on_rails_pro/app/helpers/react_on_rails_pro_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def consumer_stream_async(on_complete:)
445445
rescue StandardError
446446
# Already resolved, safe to ignore
447447
end
448-
raise e
448+
raise
449449
end
450450

451451
# Wait for and return the first chunk (blocking)

react_on_rails_pro/spec/dummy/client/app/ror-auto-load-components/StreamErrorDemo.jsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ const AlwaysFailsAsync = () => {
1111

1212
const StreamErrorDemo = () => (
1313
<div style={{ fontFamily: 'sans-serif', padding: '20px' }}>
14-
<h1>Stream Error Demo (Issue #2402)</h1>
15-
<p>This component demonstrates the streaming hang bug.</p>
14+
<h1>Stream Error Demo</h1>
15+
<p>This component demonstrates stream error handling during SSR.</p>
1616
<p>The header above renders immediately as part of the shell.</p>
1717
<hr />
18-
<Suspense fallback={<div style={{ color: 'orange' }}>Loading async content (will error after 2s)...</div>}>
18+
<Suspense
19+
fallback={<div style={{ color: 'orange' }}>Loading async content (will error after 2s)...</div>}
20+
>
1921
<AlwaysFailsAsync />
2022
</Suspense>
2123
<hr />
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import React from 'react';
2-
31
const StreamShellErrorDemo = () => {
42
throw new Error('Component crashed immediately during shell render!');
5-
6-
return <div>This will never render</div>;
73
};
84

95
export default StreamShellErrorDemo;

0 commit comments

Comments
 (0)