@@ -396,22 +396,21 @@ async function load_shadow_data(route, event, prerender) {
396396 if ( result . fallthrough ) return result ;
397397
398398 const { status, headers, body } = validate_shadow_output ( result ) ;
399+ data . status = status ;
400+
399401 add_cookies ( /** @type {string[] } */ ( data . cookies ) , headers ) ;
400402
401403 // Redirects are respected...
402404 if ( status >= 300 && status < 400 ) {
403- return {
404- status,
405- redirect : /** @type {string } */ (
406- headers instanceof Headers ? headers . get ( 'location' ) : headers . location
407- )
408- } ;
405+ data . redirect = /** @type {string } */ (
406+ headers instanceof Headers ? headers . get ( 'location' ) : headers . location
407+ ) ;
408+ return data ;
409409 }
410410
411411 // ...but 4xx and 5xx status codes _don't_ result in the error page
412412 // rendering for non-GET requests — instead, we allow the page
413413 // to render with any validation errors etc that were returned
414- data . status = status ;
415414 data . body = body ;
416415 }
417416
@@ -422,21 +421,18 @@ async function load_shadow_data(route, event, prerender) {
422421
423422 const { status, headers, body } = validate_shadow_output ( result ) ;
424423 add_cookies ( /** @type {string[] } */ ( data . cookies ) , headers ) ;
424+ data . status = status ;
425425
426426 if ( status >= 400 ) {
427- return {
428- status,
429- error : new Error ( 'Failed to load data' )
430- } ;
427+ data . error = new Error ( 'Failed to load data' ) ;
428+ return data ;
431429 }
432430
433431 if ( status >= 300 ) {
434- return {
435- status,
436- redirect : /** @type {string } */ (
437- headers instanceof Headers ? headers . get ( 'location' ) : headers . location
438- )
439- } ;
432+ data . redirect = /** @type {string } */ (
433+ headers instanceof Headers ? headers . get ( 'location' ) : headers . location
434+ ) ;
435+ return data ;
440436 }
441437
442438 data . body = { ...body , ...data . body } ;
0 commit comments