// We shouldn't really run into a situation where there are multiple
// errors but since this is just a message bus, it's possible.
childErrors.push(childError);
}else{
data+=result.data;
}
});
awaitnewPromise((resolve,reject)=>{
child.on('close',(exitCode)=>{
// Exited successfully
if(exitCode===0){
resolve(data);
}else{
letextraErrorsMessage='';
if(childErrors.length>1){
extraErrorsMessage=` (somehow we saw ${childErrors.length} errors but we really always expect 1 error)`;
}
consterror=newRethrownError(
`Child process failed with exit code ${exitCode}${extraErrorsMessage}`,
childErrors[0]
);
reject(error);
}
});
// When a problem occurs when spawning the process or gets aborted
child.on('error',(err)=>{
if(err.name==='AbortError'){
thrownewRethrownError(
`Timed out while rendering Hydrogen to string so we aborted the child process after ${RENDER_TIMEOUT}ms`,
err
);
}
reject(err);
});
});
returndata;
}catch(err){
thrownewRethrownError(
`Failed to render Hydrogen to string. In order to reproduce, feed in these arguments into \`renderHydrogenToString(...)\`:\n renderToString arguments: ${JSON.stringify(