Error handling react SSR renderToNodeStream的错误处理

Error handling react SSR renderToNodeStream的错误处理,error-handling,server-side-rendering,node-streams,react-16,react-ssr,Error Handling,Server Side Rendering,Node Streams,React 16,React Ssr,我正试图找出如何正确处理react流的错误。假设中有一个错误。捕捉错误的最佳方法是什么?catch块似乎没有捕捉到错误,因为当我在组件中抛出错误时,它不会在console.log中记录任何内容。我试图添加stream.on('error',(err)=>{console.log(err)})并且这也不会捕获错误。如何在服务器端捕捉应用程序中的错误 try { const header = <div>Hello</div> const footer = <di

我正试图找出如何正确处理react流的错误。假设
中有一个错误。捕捉错误的最佳方法是什么?catch块似乎没有捕捉到错误,因为当我在
组件中抛出错误时,它不会在console.log中记录任何内容。我试图添加
stream.on('error',(err)=>{console.log(err)})并且这也不会捕获错误。如何在服务器端捕捉应用程序中的错误

try {
  const header = <div>Hello</div>
  const footer = <div>Bye</div>
  const sheet = new ServerStyleSheet();
  const jsx = sheet.collectStyles(<App />);
  const stream = sheet.interleaveWithNodeStream(renderToNodeStream(jsx));
  ctx.body = multi_stream([
    string_stream(header),
    stream,
    string_stream(footer)
  ]);
} catch (err) {
  console.log('There is an error', err);
  ctx.throw(err.status, 'Failed to SSR');
}
试试看{
const header=Hello
常量页脚=再见
const sheet=new ServerStyleSheet();
const jsx=sheet.collectStyles();
const stream=sheet.interleaveWithNodeStream(renderToNodeStream(jsx));
ctx.body=多线程流([
字符串_流(标题),
流动
字符串\u流(页脚)
]);
}捕捉(错误){
log('有一个错误',err);
ctx.throw(错误状态为“SSR失败”);
}