@@ -266,7 +266,7 @@ class EmberApp {
266266 let res = options . response ;
267267 let html = options . html || this . html ;
268268 let disableShoebox = options . disableShoebox || false ;
269- let destroyAppInstanceInMs = options . destroyAppInstanceInMs ;
269+ let destroyAppInstanceInMs = parseInt ( options . destroyAppInstanceInMs , 10 ) ;
270270
271271 let shouldRender = ( options . shouldRender !== undefined ) ? options . shouldRender : true ;
272272 let bootOptions = buildBootOptions ( shouldRender ) ;
@@ -285,23 +285,19 @@ class EmberApp {
285285 } ) ;
286286
287287 let destroyAppInstanceTimer ;
288- if ( parseInt ( destroyAppInstanceInMs , 10 ) > 0 ) {
288+ if ( destroyAppInstanceInMs > 0 ) {
289289 // start a timer to destroy the appInstance forcefully in the given ms.
290290 // This is a failure mechanism so that node process doesn't get wedged if the `visit` never completes.
291291 destroyAppInstanceTimer = setTimeout ( function ( ) {
292- if ( instance && ! result . instanceDestroyed ) {
292+ if ( result . instance && ! result . instanceDestroyed ) {
293293 result . instanceDestroyed = true ;
294294 result . error = new Error ( 'App instance was forcefully destroyed in ' + destroyAppInstanceInMs + 'ms' ) ;
295- instance . destroy ( ) ;
295+ result . instance . destroy ( ) ;
296296 }
297297 } , destroyAppInstanceInMs ) ;
298298 }
299299
300- let instance ;
301300 return this . visitRoute ( path , fastbootInfo , bootOptions , result )
302- . then ( appInstance => {
303- instance = appInstance ;
304- } )
305301 . then ( ( ) => {
306302 if ( ! disableShoebox ) {
307303 // if shoebox is not disabled, then create the shoebox and send API data
@@ -311,9 +307,9 @@ class EmberApp {
311307 . catch ( error => result . error = error )
312308 . then ( ( ) => result . _finalize ( ) )
313309 . finally ( ( ) => {
314- if ( instance && ! result . instanceDestroyed ) {
310+ if ( result . instance && ! result . instanceDestroyed ) {
315311 result . instanceDestroyed = true ;
316- instance . destroy ( ) ;
312+ result . instance . destroy ( ) ;
317313
318314 if ( destroyAppInstanceTimer ) {
319315 clearTimeout ( destroyAppInstanceTimer ) ;
0 commit comments