diff options
author | Vitaly Takmazov | 2022-11-01 21:17:08 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:58 +0300 |
commit | 4761552440b0a2cfd3dea887201f61b5ed757bb7 (patch) | |
tree | f455c7382101a3db1869e49a99afe655594dd72f /vnext/server/middleware | |
parent | 734c00bbd4a1690fd8e5149644671fd7c4adba25 (diff) |
SSR: handle shell errors
Diffstat (limited to 'vnext/server/middleware')
-rw-r--r-- | vnext/server/middleware/renderer.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/vnext/server/middleware/renderer.js b/vnext/server/middleware/renderer.js index ca2ac2df..646e7d6c 100644 --- a/vnext/server/middleware/renderer.js +++ b/vnext/server/middleware/renderer.js @@ -63,8 +63,19 @@ const serverRenderer = async (req, res) => { res.write(propsData); pipe(res, { end: false }); }, + onShellError() { + didError = true; + res.statusCode = 500; + res.setHeader('Content-type', 'text/html'); + res.send( + '<h1>Something went wrong :(</h1>' + ); + res.end(); + }, onAllReady() { - res.write(data[1]); + if (!didError) { + res.write(data[1]); + } res.end(); }, onError(err) { |