Skip to content

Commit 2cfff3b

Browse files
Fix runOnOtherBundle function parameters and improve global context handling
- Updated the parameters for the `runOnOtherBundle` function to ensure correct execution order. - Introduced a reference to `globalThis.runOnOtherBundle` in the server rendering code for better accessibility. - Enhanced the test fixture to align with the changes in the global context, ensuring consistent behavior across rendering requests.
1 parent c07dd56 commit 2cfff3b

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

react_on_rails_pro/lib/react_on_rails_pro/server_rendering_js_code.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def generate_rsc_payload_js_function(render_options)
3636
renderingRequest,
3737
rscBundleHash: '#{ReactOnRailsPro::Utils.rsc_bundle_hash}',
3838
}
39+
const runOnOtherBundle = globalThis.runOnOtherBundle;
3940
if (typeof generateRSCPayload !== 'function') {
4041
globalThis.generateRSCPayload = function generateRSCPayload(componentName, props, railsContext) {
4142
const { renderingRequest, rscBundleHash } = railsContext.serverSideRSCPayloadParameters;

react_on_rails_pro/packages/node-renderer/src/worker/vm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export async function buildExecutionContext(
342342
context.sharedExecutionContext = sharedExecutionContext;
343343
context.runOnOtherBundle = (bundleTimestamp: string | number, newRenderingRequest: string) => {
344344
const otherBundleFilePath = getRequestBundleFilePath(bundleTimestamp);
345-
return runInVM(otherBundleFilePath, newRenderingRequest, vmCluster);
345+
return runInVM(newRenderingRequest, otherBundleFilePath, vmCluster);
346346
};
347347

348348
try {

react_on_rails_pro/packages/node-renderer/tests/fixtures/projects/spec-dummy/asyncComponentsTreeForTestingRenderingRequest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
rscBundleHash: '88888-test',
99
}
1010

11+
const runOnOtherBundle = globalThis.runOnOtherBundle;
1112
if (typeof generateRSCPayload !== 'function') {
1213
globalThis.generateRSCPayload = function generateRSCPayload(componentName, props, railsContext) {
1314
const { renderingRequest, rscBundleHash } = railsContext.serverSideRSCPayloadParameters;

0 commit comments

Comments
 (0)