Skip to content

Commit cd28f69

Browse files
gnoffunstubbable
authored andcommitted
Update metadata to await the generation so we get a proper codeframe
in theory this shouldn't be necessary but currently we only track awaits and just rendering the promise as is doesn't cause there to be and IO stack line to generate a codeframe off of
1 parent 4013cd5 commit cd28f69

File tree

4 files changed

+170
-53
lines changed

4 files changed

+170
-53
lines changed

packages/next/src/lib/metadata/metadata.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ export function createMetadataComponents({
8181
workStore
8282
)
8383

84-
function Viewport() {
85-
const pendingViewportTags = getResolvedViewport(
84+
async function Viewport() {
85+
const tags = await getResolvedViewport(
8686
tree,
8787
searchParams,
8888
getDynamicParamFromSegment,
@@ -107,17 +107,20 @@ export function createMetadataComponents({
107107
return null
108108
})
109109

110+
return tags
111+
}
112+
Viewport.displayName = 'Next.Viewport'
113+
114+
function ViewportWrapper() {
110115
return (
111116
<ViewportBoundary>
112-
{/* @ts-expect-error -- Promise<ReactNode> not considered a valid child even though it is */}
113-
{pendingViewportTags}
117+
<Viewport />
114118
</ViewportBoundary>
115119
)
116120
}
117-
Viewport.displayName = 'Next.Viewport'
118121

119-
function Metadata() {
120-
const pendingMetadataTags = getResolvedMetadata(
122+
async function Metadata() {
123+
const tags = await getResolvedMetadata(
121124
tree,
122125
pathnameForMetadata,
123126
searchParams,
@@ -146,29 +149,31 @@ export function createMetadataComponents({
146149
return null
147150
})
148151

152+
return tags
153+
}
154+
Metadata.displayName = 'Next.Metadata'
155+
156+
function MetadataWrapper() {
149157
// TODO: We shouldn't change what we render based on whether we are streaming or not.
150158
// If we aren't streaming we should just block the response until we have resolved the
151159
// metadata.
152160
if (!serveStreamingMetadata) {
153161
return (
154162
<MetadataBoundary>
155-
{/* @ts-expect-error -- Promise<ReactNode> not considered a valid child even though it is */}
156-
{pendingMetadataTags}
163+
<Metadata />
157164
</MetadataBoundary>
158165
)
159166
}
160167
return (
161168
<div hidden>
162169
<MetadataBoundary>
163170
<Suspense name="Next.Metadata">
164-
{/* @ts-expect-error -- Promise<ReactNode> not considered a valid child even though it is */}
165-
{pendingMetadataTags}
171+
<Metadata />
166172
</Suspense>
167173
</MetadataBoundary>
168174
</div>
169175
)
170176
}
171-
Metadata.displayName = 'Next.Metadata'
172177

173178
function MetadataOutlet() {
174179
const pendingOutlet = Promise.all([
@@ -205,8 +210,8 @@ export function createMetadataComponents({
205210
MetadataOutlet.displayName = 'Next.MetadataOutlet'
206211

207212
return {
208-
Viewport,
209-
Metadata,
213+
Viewport: ViewportWrapper,
214+
Metadata: MetadataWrapper,
210215
MetadataOutlet,
211216
}
212217
}

packages/next/src/next-devtools/dev-overlay/components/errors/error-type-label/error-type-label.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type ErrorType =
44
| `Console ${string}`
55
| `Recoverable ${string}`
66
| 'Blocking Route'
7+
| 'Ambiguous Metadata'
78

89
type ErrorTypeLabelProps = {
910
errorType: ErrorType
@@ -13,7 +14,7 @@ export function ErrorTypeLabel({ errorType }: ErrorTypeLabelProps) {
1314
return (
1415
<span
1516
id="nextjs__container_errors_label"
16-
className={`nextjs__container_errors_label ${errorType === 'Blocking Route' ? 'nextjs__container_errors_label_blocking_page' : ''}`}
17+
className={`nextjs__container_errors_label ${errorType === 'Blocking Route' || errorType === 'Ambiguous Metadata' ? 'nextjs__container_errors_label_blocking_page' : ''}`}
1718
>
1819
{errorType}
1920
</span>

0 commit comments

Comments
 (0)