@@ -48,9 +48,12 @@ import {
4848import { scheduleOnNextTick } from '../../lib/scheduler'
4949import { BailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
5050import {
51- bodyMessage ,
52- metadataMessage ,
53- viewportMessage ,
51+ runtimeBodyMessage ,
52+ dynamicBodyMessage ,
53+ runtimeMetadataMessage ,
54+ dynamicMetadataMessage ,
55+ runtimeViewportMessage ,
56+ dynamicViewportMessage ,
5457 disallowedDynamicViewportMessage ,
5558 disallowedDynamicMetadataMessage ,
5659} from './blocking-route-messages'
@@ -817,13 +820,12 @@ export function trackAllowedDynamicAccess(
817820 dynamicValidation . hasAllowedDynamic = true
818821 return
819822 } else if ( clientDynamic . syncDynamicErrorWithStack ) {
820- // This task was the task that called the sync error.
821- dynamicValidation . dynamicErrors . push (
822- clientDynamic . syncDynamicErrorWithStack
823- )
823+ const syncError = clientDynamic . syncDynamicErrorWithStack
824+ syncError . message = runtimeBodyMessage ( workStore . route )
825+ dynamicValidation . dynamicErrors . push ( syncError )
824826 return
825827 } else {
826- const message = bodyMessage ( workStore . route )
828+ const message = dynamicBodyMessage ( workStore . route )
827829 const error = addErrorContext ( new Error ( message ) , componentStack , null )
828830 dynamicValidation . dynamicErrors . push ( error )
829831 return
@@ -873,7 +875,7 @@ export function trackDynamicHoleInNavigation(
873875 componentStack : string ,
874876 dynamicValidation : InstantValidationState ,
875877 clientDynamic : DynamicTrackingState ,
876- _kind : DynamicHoleKind ,
878+ kind : DynamicHoleKind ,
877879 boundaryState : ValidationBoundaryTracking
878880) {
879881 if ( hasOutletRegex . test ( componentStack ) ) {
@@ -889,7 +891,10 @@ export function trackDynamicHoleInNavigation(
889891 )
890892
891893 if ( hasMetadataRegex . test ( componentStack ) ) {
892- const message = metadataMessage ( workStore . route )
894+ const message =
895+ kind === DynamicHoleKind . Runtime
896+ ? runtimeMetadataMessage ( workStore . route )
897+ : dynamicMetadataMessage ( workStore . route )
893898 const error = addErrorContext (
894899 new Error ( message ) ,
895900 componentStack ,
@@ -899,7 +904,10 @@ export function trackDynamicHoleInNavigation(
899904 return
900905 }
901906 if ( hasViewportRegex . test ( componentStack ) ) {
902- const message = viewportMessage ( workStore . route )
907+ const message =
908+ kind === DynamicHoleKind . Runtime
909+ ? runtimeViewportMessage ( workStore . route )
910+ : dynamicViewportMessage ( workStore . route )
903911 const error = addErrorContext (
904912 new Error ( message ) ,
905913 componentStack ,
@@ -971,16 +979,19 @@ export function trackDynamicHoleInNavigation(
971979 }
972980
973981 if ( clientDynamic . syncDynamicErrorWithStack ) {
974- // This task was the task that called the sync error.
975982 const syncError = clientDynamic . syncDynamicErrorWithStack
983+ syncError . message = runtimeBodyMessage ( workStore . route )
976984 if ( effectiveCreateInstantStack !== null && syncError . cause === undefined ) {
977985 syncError . cause = effectiveCreateInstantStack ( )
978986 }
979987 dynamicValidation . dynamicErrors . push ( syncError )
980988 return
981989 }
982990
983- const message = bodyMessage ( workStore . route )
991+ const message =
992+ kind === DynamicHoleKind . Runtime
993+ ? runtimeBodyMessage ( workStore . route )
994+ : dynamicBodyMessage ( workStore . route )
984995 const error = addErrorContext (
985996 new Error ( message ) ,
986997 componentStack ,
@@ -1052,15 +1063,15 @@ export function trackDynamicHoleInRuntimeShell(
10521063 // We don't need to track that this is dynamic. It is only so when something else is also dynamic.
10531064 return
10541065 } else if ( hasMetadataRegex . test ( componentStack ) ) {
1055- const message = metadataMessage ( workStore . route )
1066+ const message = dynamicMetadataMessage ( workStore . route )
10561067 const error = addErrorContext ( new Error ( message ) , componentStack , null )
10571068 dynamicValidation . dynamicMetadata = error
10581069 return
10591070 } else if ( hasViewportRegex . test ( componentStack ) ) {
10601071 // TODO(instant-validation): If the page only has holes caused by runtime data,
10611072 // we won't find out if there's a suspense-above-body and error for dynamic viewport
10621073 // even if there is in fact a suspense-above-body
1063- const message = viewportMessage ( workStore . route )
1074+ const message = dynamicViewportMessage ( workStore . route )
10641075 const error = addErrorContext ( new Error ( message ) , componentStack , null )
10651076 dynamicValidation . dynamicErrors . push ( error )
10661077 return
@@ -1081,14 +1092,13 @@ export function trackDynamicHoleInRuntimeShell(
10811092 dynamicValidation . hasAllowedDynamic = true
10821093 return
10831094 } else if ( clientDynamic . syncDynamicErrorWithStack ) {
1084- // This task was the task that called the sync error.
1085- dynamicValidation . dynamicErrors . push (
1086- clientDynamic . syncDynamicErrorWithStack
1087- )
1095+ const syncError = clientDynamic . syncDynamicErrorWithStack
1096+ syncError . message = runtimeBodyMessage ( workStore . route )
1097+ dynamicValidation . dynamicErrors . push ( syncError )
10881098 return
10891099 }
10901100
1091- const message = bodyMessage ( workStore . route )
1101+ const message = runtimeBodyMessage ( workStore . route )
10921102 const error = addErrorContext ( new Error ( message ) , componentStack , null )
10931103 dynamicValidation . dynamicErrors . push ( error )
10941104 return
@@ -1104,12 +1114,12 @@ export function trackDynamicHoleInStaticShell(
11041114 // We don't need to track that this is dynamic. It is only so when something else is also dynamic.
11051115 return
11061116 } else if ( hasMetadataRegex . test ( componentStack ) ) {
1107- const message = metadataMessage ( workStore . route )
1117+ const message = runtimeMetadataMessage ( workStore . route )
11081118 const error = addErrorContext ( new Error ( message ) , componentStack , null )
11091119 dynamicValidation . dynamicMetadata = error
11101120 return
11111121 } else if ( hasViewportRegex . test ( componentStack ) ) {
1112- const message = viewportMessage ( workStore . route )
1122+ const message = runtimeViewportMessage ( workStore . route )
11131123 const error = addErrorContext ( new Error ( message ) , componentStack , null )
11141124 dynamicValidation . dynamicErrors . push ( error )
11151125 return
@@ -1130,13 +1140,12 @@ export function trackDynamicHoleInStaticShell(
11301140 dynamicValidation . hasAllowedDynamic = true
11311141 return
11321142 } else if ( clientDynamic . syncDynamicErrorWithStack ) {
1133- // This task was the task that called the sync error.
1134- dynamicValidation . dynamicErrors . push (
1135- clientDynamic . syncDynamicErrorWithStack
1136- )
1143+ const syncError = clientDynamic . syncDynamicErrorWithStack
1144+ syncError . message = runtimeBodyMessage ( workStore . route )
1145+ dynamicValidation . dynamicErrors . push ( syncError )
11371146 return
11381147 } else {
1139- const message = bodyMessage ( workStore . route )
1148+ const message = dynamicBodyMessage ( workStore . route )
11401149 const error = addErrorContext ( new Error ( message ) , componentStack , null )
11411150 dynamicValidation . dynamicErrors . push ( error )
11421151 return
0 commit comments