File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,30 @@ export async function render(path: string) {
77 const { app, router } = await createApp ( )
88 await router . go ( path )
99 const ctx : SSGContext = { content : '' , vpSocialIcons : new Set < string > ( ) }
10+
11+ // Vue's SSR renderer reports component errors through the app's error
12+ // handler and continues rendering instead of rejecting renderToString,
13+ // which would silently ship broken pages. Collect the errors and fail
14+ // the build instead.
15+ const errors : [ unknown , string ] [ ] = [ ]
16+ const userErrorHandler = app . config . errorHandler
17+ app . config . errorHandler = ( err , instance , info ) => {
18+ errors . push ( [ err , info ] )
19+ userErrorHandler ?.( err , instance , info )
20+ }
21+
1022 ctx . content = await renderToString ( app , ctx )
23+
24+ if ( errors . length ) {
25+ const details = errors
26+ . map ( ( [ err , info ] ) =>
27+ err instanceof Error
28+ ? `[${ info } ] ${ err . stack || err . message } `
29+ : `[${ info } ] ${ String ( err ) } `
30+ )
31+ . join ( '\n' )
32+ throw new Error ( `Errors during SSR rendering of ${ path } :\n${ details } ` )
33+ }
34+
1135 return ctx
1236}
You can’t perform that action at this time.
0 commit comments