@@ -186,7 +186,7 @@ class EmberApp {
186186 * Create the ember application in the sandbox.
187187 *
188188 */
189- createEmberApp ( sandbox ) {
189+ createEmberApp ( sandbox ) {
190190 // Retrieve the application factory from within the sandbox
191191 let AppFactory = sandbox . run ( function ( ctx ) {
192192 return ctx . require ( '~fastboot/app-factory' ) ;
@@ -288,7 +288,7 @@ class EmberApp {
288288 * @param {ClientResponse }
289289 * @returns {Promise<Result> } result
290290 */
291- visit ( path , options ) {
291+ async visit ( path , options ) {
292292 let req = options . request ;
293293 let res = options . response ;
294294 let html = options . html || this . html ;
@@ -319,22 +319,27 @@ class EmberApp {
319319 } , destroyAppInstanceInMs ) ;
320320 }
321321
322- return this . visitRoute ( path , fastbootInfo , bootOptions , result )
323- . then ( ( ) => {
324- if ( ! disableShoebox ) {
325- // if shoebox is not disabled, then create the shoebox and send API data
326- createShoebox ( doc , fastbootInfo ) ;
327- }
328- } )
329- . catch ( error => ( result . error = error ) )
330- . then ( ( ) => result . _finalize ( ) )
331- . finally ( ( ) => {
332- if ( result . _destroyAppInstance ( ) ) {
333- if ( destroyAppInstanceTimer ) {
334- clearTimeout ( destroyAppInstanceTimer ) ;
335- }
322+ try {
323+ await this . visitRoute ( path , fastbootInfo , bootOptions , result ) ;
324+
325+ if ( ! disableShoebox ) {
326+ // if shoebox is not disabled, then create the shoebox and send API data
327+ createShoebox ( doc , fastbootInfo ) ;
328+ }
329+
330+ result . _finalize ( ) ;
331+ } catch ( error ) {
332+ // eslint-disable-next-line require-atomic-updates
333+ result . error = error ;
334+ } finally {
335+ if ( result . _destroyAppInstance ( ) ) {
336+ if ( destroyAppInstanceTimer ) {
337+ clearTimeout ( destroyAppInstanceTimer ) ;
336338 }
337- } ) ;
339+ }
340+ }
341+
342+ return result ;
338343 }
339344
340345 /**
0 commit comments