Skip to content

Commit 52bcbe3

Browse files
Fix debug output path construction in VM
Use bundlePath from config instead of bundleFilePath to avoid incorrect path construction like `bundle.js/code.js`.
1 parent 8107864 commit 52bcbe3

File tree

1 file changed

+3
-2
lines changed
  • react_on_rails_pro/packages/node-renderer/src/worker

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ export async function buildExecutionContext(
317317

318318
const runInVM = async (renderingRequest: string, bundleFilePath: string, vmCluster?: typeof cluster) => {
319319
try {
320+
const { bundlePath } = getConfig();
320321
const vmContext = mapBundleFilePathToVMContext.get(bundleFilePath);
321322
if (!vmContext) {
322323
throw new VMContextNotFoundError(bundleFilePath);
@@ -332,7 +333,7 @@ export async function buildExecutionContext(
332333
const workerId = vmCluster?.worker?.id;
333334
log.debug(`worker ${workerId ? `${workerId} ` : ''}received render request for bundle ${bundleFilePath} with code
334335
${smartTrim(renderingRequest)}`);
335-
const debugOutputPathCode = path.join(bundleFilePath, 'code.js');
336+
const debugOutputPathCode = path.join(bundlePath, 'code.js');
336337
log.debug(`Full code executed written to: ${debugOutputPathCode}`);
337338
await writeFileAsync(debugOutputPathCode, renderingRequest);
338339
}
@@ -368,7 +369,7 @@ export async function buildExecutionContext(
368369
if (log.level === 'debug') {
369370
log.debug(`result from JS:
370371
${smartTrim(result)}`);
371-
const debugOutputPathResult = path.join(bundleFilePath, 'result.json');
372+
const debugOutputPathResult = path.join(bundlePath, 'result.json');
372373
log.debug(`Wrote result to file: ${debugOutputPathResult}`);
373374
await writeFileAsync(debugOutputPathResult, result);
374375
}

0 commit comments

Comments
 (0)