@@ -117,7 +117,7 @@ function renderDevelopment(
117117 ` ) ;
118118}
119119
120- function renderProduction ( request , response ) {
120+ function renderProduction ( request , response , next ? ) {
121121 const route = request . currentRoute ;
122122 const serverIndexPath = path . resolve (
123123 getRouteBuildPath ( route ) ,
@@ -165,12 +165,19 @@ function renderProduction(request, response) {
165165 } )
166166 . catch ( ( e ) => {
167167 error ( e ) ;
168+ // This render runs inside a floated promise, so a throw here never reaches
169+ // the calling middleware's try/catch. Without forwarding it, the request
170+ // hangs until the socket/requestTimeout fires (no status, no body). Hand it
171+ // to the error handler so the client gets a proper 500 instead.
172+ if ( typeof next === 'function' && ! response . headersSent ) {
173+ next ( e ) ;
174+ }
168175 } ) ;
169176}
170177
171- export function render ( request , response ) {
178+ export function render ( request , response , next ? ) {
172179 if ( isProductionMode ( ) ) {
173- renderProduction ( request , response ) ;
180+ renderProduction ( request , response , next ) ;
174181 } else {
175182 renderDevelopment ( request , response ) ;
176183 }
0 commit comments