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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,16 @@ You can find the **package** version numbers from this repo's tags and below in
16
16
## [Unreleased]
17
17
*Add changes in master not yet tagged.*
18
18
19
+
### Improved
20
+
- Improved RSC rendering flow by eliminating double rendering of server components and reducing the number of HTTP requests.
21
+
- Updated communication protocol between Node Renderer and Rails to version 2.0.0 which supports the ability to upload multiple bundles at once.
22
+
- Added the ability to communicate between different bundles on the renderer by using the `runOnOtherBundle` function which is globally available for the rendering request.
23
+
24
+
[PR 515](https://github.com/shakacode/react_on_rails_pro/pull/515) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
25
+
26
+
27
+
## [4.0.0-rc.13] - 2025-03-07
28
+
19
29
### Added
20
30
- 🚀 **Introducing React Server Components Support!** 🎉
21
31
- Experience the future of React with full RSC integration
Copy file name to clipboardExpand all lines: docs/node-renderer/js-configuration.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Here are the options available for the JavaScript renderer configuration object,
17
17
1.**logHttpLevel** (default: `process.env.RENDERER_LOG_HTTP_LEVEL || 'error'`) - The HTTP server log level (same allowed values as `logLevel`).
18
18
1.**fastifyServerOptions** (default: `{}`) - Additional options to pass to the Fastify server factory. See [Fastify documentation](https://fastify.dev/docs/latest/Reference/Server/#factory).
19
19
1.**bundlePath** (default: `process.env.RENDERER_BUNDLE_PATH || '/tmp/react-on-rails-pro-node-renderer-bundles'` ) - path to a temp directory where uploaded bundle files will be stored. For example you can set it to `path.resolve(__dirname, './.node-renderer-bundles')` if you configured renderer from the `/` directory of your app.
20
-
1.**workersCount** (default: `env.RENDERER_WORKERS_COUNT || defaultWorkersCount()` where default is your CPUs count - 1) - Number of workers that will be forked to serve rendering requests. If you set this manually make sure that value is a **Number** and is `>= 1`.
20
+
1.**workersCount** (default: `env.RENDERER_WORKERS_COUNT || defaultWorkersCount()` where default is your CPUs count - 1) - Number of workers that will be forked to serve rendering requests. If you set this manually make sure that value is a **Number** and is `>= 0`. Setting this to `0` will run the renderer in a single process mode without forking any workers, which is useful for debugging purposes. For production use, the value should be `>= 1`.
21
21
1.**password** (default: `env.RENDERER_PASSWORD`) - The password expected to receive from the **Rails client** to authenticate rendering requests.
22
22
If no password is set, no authentication will be required.
23
23
1.**allWorkersRestartInterval** (default: `env.RENDERER_ALL_WORKERS_RESTART_INTERVAL`) - Interval in minutes between scheduled restarts of all workers. By default restarts are not enabled. If restarts are enabled, `delayBetweenIndividualWorkerRestarts` should also be set.
@@ -63,10 +63,14 @@ const config = {
63
63
// All other values are the defaults, as described above
64
64
};
65
65
66
+
// For debugging, run in single process mode
67
+
if (process.env.NODE_ENV==='development') {
68
+
config.workersCount=0;
69
+
}
66
70
// Renderer detects a total number of CPUs on virtual hostings like Heroku or CircleCI instead
67
71
// of CPUs number allocated for current container. This results in spawning many workers while
RSCBundle-->>NodeRenderer: RSC payload with:<br/>- Server components<br/>- Client component refs
81
-
NodeRenderer-->>Browser: Stream RSC payload
82
-
83
-
Note over Browser: 3. Client Hydration
84
-
Browser->>Browser: Process RSC payload
85
-
loop For each client component
86
-
Browser->>Browser: Fetch component chunk
87
-
Browser->>Browser: Hydrate component
88
-
end
89
-
```
90
-
91
-
> [!NOTE]
92
-
> For simplicity, this diagram shows the RSC payload being fetched after the HTML is fully streamed to the client. In reality, the browser begins fetching the RSC payload and starts hydration immediately as soon as it receives the necessary HTML, without waiting for the complete page to be streamed. This parallel processing enables faster page interactivity and better performance.
93
-
94
-
## Future Improvements
95
-
96
-
These inefficiencies will be addressed in the upcoming ["Use RSC payload to render server components on server"](https://github.com/shakacode/react_on_rails_pro/pull/515) PR. The new flow will be:
97
-
98
-
1. Initial Request:
99
-
-`stream_react_component` triggers node renderer
100
-
- Renderer uses **RSC Bundle** to generate RSC payload
101
-
- Payload is passed to rendering function in **Server Bundle**
102
-
- HTML of server components is generated using RSC payload
103
-
- Client component references are filled with HTML of the client components
104
-
105
-
2. Single Response:
106
-
- HTML and RSC payload are streamed together, with the RSC payload embedded inside the HTML page
107
48
- Browser displays HTML immediately
108
-
- React runtime uses embedded RSC payload for hydration
109
-
- Client components are hydrated progressively
49
+
- React runtime uses the embedded RSC payload for hydration
50
+
- Client components are hydrated progressively without requiring a separate HTTP request
110
51
111
-
This improved approach eliminates double rendering and reduces HTTP requests, resulting in better performance and resource utilization.
52
+
This approach offers significant advantages:
53
+
- Eliminates double rendering of server components
54
+
- Reduces HTTP requests by embedding the RSC payload within the initial HTML response
55
+
- Provides faster interactivity through streamlined rendering and hydration
112
56
113
57
```mermaid
114
58
sequenceDiagram
@@ -121,9 +65,9 @@ sequenceDiagram
121
65
Note over Browser,ServerBundle: 1. Initial Request
0 commit comments