@@ -1028,13 +1028,23 @@ function runNodeBenchmark(script, timeout) {
10281028 execFile ( process . execPath , [ "-e" , script ] , {
10291029 windowsHide : true ,
10301030 timeout,
1031- maxBuffer : 1024 * 256
1031+ maxBuffer : 1024 * 256 ,
1032+ env : { ...process . env , ELECTRON_RUN_AS_NODE : "1" }
10321033 } , ( error , stdout , stderr ) => {
10331034 if ( error ) {
10341035 reject ( new Error ( `${ error . message } \n${ stderr || "" } ` ) ) ;
10351036 return ;
10361037 }
1037- resolve ( JSON . parse ( stdout . trim ( ) ) ) ;
1038+ const output = stdout . trim ( ) ;
1039+ if ( ! output ) {
1040+ reject ( new Error ( `Benchmark worker produced no JSON output.${ stderr ? `\n${ stderr } ` : "" } ` ) ) ;
1041+ return ;
1042+ }
1043+ try {
1044+ resolve ( JSON . parse ( output ) ) ;
1045+ } catch ( parseError ) {
1046+ reject ( new Error ( `Benchmark worker returned invalid JSON: ${ parseError . message } \n${ output . slice ( 0 , 500 ) } ` ) ) ;
1047+ }
10381048 } ) ;
10391049 } ) ;
10401050}
@@ -1109,7 +1119,8 @@ function startCpuStress({ durationSec = 60, workers } = {}) {
11091119 cpuStress . workers = Array . from ( { length : workerCount } , ( ) => {
11101120 const child = spawn ( process . execPath , [ "-e" , cpuStressChildScript ] , {
11111121 windowsHide : true ,
1112- stdio : [ "ignore" , "pipe" , "ignore" , "ipc" ]
1122+ stdio : [ "ignore" , "pipe" , "ignore" , "ipc" ] ,
1123+ env : { ...process . env , ELECTRON_RUN_AS_NODE : "1" }
11131124 } ) ;
11141125 child . stdout . setEncoding ( "utf8" ) ;
11151126 child . stdout . on ( "data" , ( chunk ) => {
@@ -1184,7 +1195,7 @@ function startMemoryStress({ durationSec = 60, targetMb } = {}) {
11841195 const child = spawn ( process . execPath , [ "-e" , memoryStressChildScript ] , {
11851196 windowsHide : true ,
11861197 stdio : [ "ignore" , "pipe" , "ignore" , "ipc" ] ,
1187- env : { ...process . env , RIGSCOPE_MEMORY_MB : String ( capped ) }
1198+ env : { ...process . env , ELECTRON_RUN_AS_NODE : "1" , RIGSCOPE_MEMORY_MB : String ( capped ) }
11881199 } ) ;
11891200 memoryStress . child = child ;
11901201 child . stdout . setEncoding ( "utf8" ) ;
0 commit comments