Subscribe on changes!

Allow SSR Errors to be handled by server/entrypoint

avatar
Mar 26th 2021

What problem does this feature solve?

The default behaviour when throwing errors seems to be to log it, and continue.

e.g.

https://github.com/vuejs/vue-next/blob/0a583d5ca224d2cba878dc6b0fb8d468e658f1ef/packages/server-renderer/src/render.ts#L94

https://github.com/vuejs/vue-next/blob/4d20ac8173f84c87288255dcc03c62a6ee862a23/packages/runtime-core/src/errorHandling.ts#L163

This makes it almost impossible to render a nice error page with a proper status code when an error is encountered in SSR. There are also many instances in which we'd want to render an error page in client too.

It would be great if we could choose to abort rendering as soon as an error is encountered, and handle the error in our entrypoint file, or in express.js. Or if we could have a canonical way of rendering error pages.

What does the proposed API look like?

Either

  • allow hooks such as created and serverPrefetch to trigger errorCaptured and abort rendering the component, or
  • allow adding a property to errors, which would prevent them being caught, and allow them to bubble up to whatever method called renderToString
avatar
Mar 26th 2021

Duplicate of #2736 ?

avatar
Mar 26th 2021

Should be fixed by d668d48e

avatar
Mar 26th 2021

@edison1105 @yyx990803 Thanks. This still leaves serverPrefetch no bubbling up errors though?

https://github.com/vuejs/vue-next/blob/0a583d5ca224d2cba878dc6b0fb8d468e658f1ef/packages/server-renderer/src/render.ts#L99

Is there a reason for this?