@@ -230,13 +230,13 @@ class EmberApp {
230230 return this . buildAppInstance ( )
231231 . then ( instance => {
232232 result . instance = instance ;
233+ result . _startDestroyTimer ( ) ;
233234 registerFastBootInfo ( fastbootInfo , instance ) ;
234235 return instance . boot ( bootOptions ) ;
235236 } )
236237 . then ( ( ) => result . instanceBooted = true )
237238 . then ( ( ) => result . instance . visit ( path , bootOptions ) )
238- . then ( ( ) => fastbootInfo . deferredPromise )
239- . then ( ( ) => result ) ;
239+ . then ( ( ) => fastbootInfo . deferredPromise ) ;
240240 }
241241
242242 /**
@@ -271,29 +271,13 @@ class EmberApp {
271271 let shouldRender = ( options . shouldRender !== undefined ) ? options . shouldRender : true ;
272272 let bootOptions = buildBootOptions ( shouldRender ) ;
273273 let fastbootInfo = new FastBootInfo (
274- req ,
275- res ,
274+ req , res ,
276275 { hostWhitelist : this . hostWhitelist , metadata : options . metadata }
277276 ) ;
278277
279278 let doc = bootOptions . document ;
280279
281- let result = new Result ( {
282- doc : doc ,
283- html : html ,
284- fastbootInfo : fastbootInfo
285- } ) ;
286-
287- let destroyAppInstanceTimer ;
288- if ( destroyAppInstanceInMs > 0 ) {
289- // start a timer to destroy the appInstance forcefully in the given ms.
290- // This is a failure mechanism so that node process doesn't get wedged if the `visit` never completes.
291- destroyAppInstanceTimer = setTimeout ( function ( ) {
292- if ( result . _destroyAppInstance ( ) ) {
293- result . error = new Error ( 'App instance was forcefully destroyed in ' + destroyAppInstanceInMs + 'ms' ) ;
294- }
295- } , destroyAppInstanceInMs ) ;
296- }
280+ let result = new Result ( { doc, html, fastbootInfo, destroyAppInstanceInMs } ) ;
297281
298282 return this . visitRoute ( path , fastbootInfo , bootOptions , result )
299283 . then ( ( ) => {
@@ -304,13 +288,7 @@ class EmberApp {
304288 } )
305289 . catch ( error => result . error = error )
306290 . then ( ( ) => result . _finalize ( ) )
307- . finally ( ( ) => {
308- if ( result . _destroyAppInstance ( ) ) {
309- if ( destroyAppInstanceTimer ) {
310- clearTimeout ( destroyAppInstanceTimer ) ;
311- }
312- }
313- } ) ;
291+ . finally ( ( ) => result . _destroyAppInstance ( ) ) ;
314292 }
315293
316294 /**
0 commit comments