Commit 2d4735bc authored by Evan You's avatar Evan You Committed by GitHub

Merge pull request #53 from isairz/ssr-error

server-side-rendering error handling
parents 7a932e9f aa3e1abb
...@@ -59,10 +59,9 @@ app.get('*', (req, res) => { ...@@ -59,10 +59,9 @@ app.get('*', (req, res) => {
const renderStream = renderer.renderToStream(context) const renderStream = renderer.renderToStream(context)
let firstChunk = true let firstChunk = true
res.write(html.head)
renderStream.on('data', chunk => { renderStream.on('data', chunk => {
if (firstChunk) { if (firstChunk) {
res.write(html.head)
// embed initial store state // embed initial store state
if (context.initialState) { if (context.initialState) {
res.write( res.write(
...@@ -82,7 +81,9 @@ app.get('*', (req, res) => { ...@@ -82,7 +81,9 @@ app.get('*', (req, res) => {
}) })
renderStream.on('error', err => { renderStream.on('error', err => {
throw err // Render Error Page or Redirect
res.status(500).end('Internal Error 500')
console.error(`error during render : ${req.url}`)
}) })
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment