Commit 9b536a4
Improve concurrent streaming error handling and configuration
This commit addresses several critical issues and improvements for concurrent
component streaming in React on Rails Pro:
1. CRITICAL: Client Disconnect Handling
- Added IOError and Errno::EPIPE exception handling in producer tasks
- Added stream.closed? check before expensive operations
- Added exception handling in writer task to stop gracefully on disconnect
- Prevents wasted resources when clients disconnect mid-stream
2. Configuration Validation Improvements
- Replaced attr_accessor with custom setter for concurrent_component_streaming_buffer_size
- Added validation at assignment time, not just initialization
- Added comprehensive documentation about memory implications
- Documented that buffer size * chunk size determines max memory usage
3. Documentation Enhancements
- Added detailed comments explaining producer-consumer pattern
- Documented ordering guarantees for concurrent streaming
- Clarified that chunks from same component maintain order
- Clarified that chunks from different components may interleave
- Added memory management documentation to drain_streams_concurrently
4. Testing
- Added test for client disconnect scenario
- Verifies producer stops when client disconnects
- Ensures no further processing after IOError
Changes:
- react_on_rails_pro/lib/react_on_rails_pro/concerns/stream.rb
- react_on_rails_pro/lib/react_on_rails_pro/configuration.rb
- react_on_rails_pro/spec/dummy/spec/helpers/react_on_rails_pro_helper_spec.rb
Note: Did not implement sleep-based test synchronization improvements as the
existing approach is acceptable for test purposes and more complex synchronization
mechanisms would add unnecessary complexity to the test suite.1 parent 62e2995 commit 9b536a4
File tree
3 files changed
+101
-1
lines changed- react_on_rails_pro
- lib/react_on_rails_pro
- concerns
- spec/dummy/spec/helpers
3 files changed
+101
-1
lines changedLines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
50 | 64 | | |
51 | 65 | | |
52 | 66 | | |
| |||
58 | 72 | | |
59 | 73 | | |
60 | 74 | | |
| 75 | + | |
61 | 76 | | |
| 77 | + | |
62 | 78 | | |
63 | 79 | | |
64 | 80 | | |
| |||
78 | 94 | | |
79 | 95 | | |
80 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
81 | 100 | | |
82 | 101 | | |
83 | 102 | | |
84 | 103 | | |
85 | 104 | | |
86 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
87 | 109 | | |
88 | 110 | | |
89 | 111 | | |
| |||
97 | 119 | | |
98 | 120 | | |
99 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
100 | 125 | | |
101 | 126 | | |
102 | 127 | | |
| |||
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
74 | 98 | | |
75 | 99 | | |
76 | 100 | | |
| |||
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
512 | 512 | | |
513 | 513 | | |
514 | 514 | | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
515 | 566 | | |
516 | 567 | | |
517 | 568 | | |
| |||
0 commit comments