Commit da2d9c55 authored by Janka Uryga's avatar Janka Uryga

debug logs and some other wip stuff idk

parent 7ba11aa3
...@@ -57,7 +57,8 @@ async fn dynamic_image_metadata_with_generator_source( ...@@ -57,7 +57,8 @@ async fn dynamic_image_metadata_with_generator_source(
const imageModule = {{ {exported_fields_excluding_default} }} const imageModule = {{ {exported_fields_excluding_default} }}
export default async function (props) {{ export default async function (props) {{
const {{ __metadata_id__: _, ...params }} = await props.params // const {{ __metadata_id__: _, ...params }} = await props.params
const params = await props.params
const imageUrl = fillDynamicMetadataSegment({pathname_prefix}, {page_segment}, params) const imageUrl = fillDynamicMetadataSegment({pathname_prefix}, {page_segment}, params)
const {{ generateImageMetadata }} = imageModule const {{ generateImageMetadata }} = imageModule
...@@ -128,11 +129,13 @@ async fn dynamic_image_metadata_without_generator_source( ...@@ -128,11 +129,13 @@ async fn dynamic_image_metadata_without_generator_source(
r#" r#"
import {{ {exported_fields_excluding_default} }} from {resource_path} import {{ {exported_fields_excluding_default} }} from {resource_path}
import {{ fillDynamicMetadataSegment }} from 'next/dist/lib/metadata/get-metadata-route' import {{ fillDynamicMetadataSegment }} from 'next/dist/lib/metadata/get-metadata-route'
import {{ excludeMetadataIdFromServerParams }} from 'next/dist/server/app-render/instant-validation/metadata-image-params'
const imageModule = {{ {exported_fields_excluding_default} }} const imageModule = {{ {exported_fields_excluding_default} }}
export default async function (props) {{ export default async function (props) {{
const {{ __metadata_id__: _, ...params }} = await props.params // const {{ __metadata_id__: _, ...params }} = await props.params
const params = await props.params
const imageUrl = fillDynamicMetadataSegment({pathname_prefix}, {page_segment}, params) const imageUrl = fillDynamicMetadataSegment({pathname_prefix}, {page_segment}, params)
function getImageMetadata(imageMetadata, idParam) {{ function getImageMetadata(imageMetadata, idParam) {{
......
...@@ -562,32 +562,42 @@ function createSegmentProps( ...@@ -562,32 +562,42 @@ function createSegmentProps(
: props : props
} }
let nextId = 0
async function collectStaticImagesFiles( async function collectStaticImagesFiles(
metadata: AppDirModules['metadata'], metadata: AppDirModules['metadata'],
props: SegmentProps, props: SegmentProps,
type: 'icon' | 'apple' | 'openGraph' | 'twitter' type: 'icon' | 'apple' | 'openGraph' | 'twitter',
segment?: string
) { ) {
if (!metadata?.[type]) return undefined if (!metadata?.[type]) return undefined
const id = nextId++
console.log(`collectStaticImagesFiles ${segment} ${id} - ${type} - start`)
try {
const iconPromises = metadata[type].map( const iconPromises = metadata[type].map(
async (imageModule: (p: SegmentProps) => Promise<MetadataImageModule[]>) => async (
await imageModule(props) imageModule: (p: SegmentProps) => Promise<MetadataImageModule[]>
) => await imageModule(props)
) )
return iconPromises?.length > 0 return iconPromises?.length > 0
? (await Promise.all(iconPromises)).flat() ? (await Promise.all(iconPromises)).flat()
: undefined : undefined
} finally {
console.log(`collectStaticImagesFiles ${segment} ${id} - ${type} - end`)
}
} }
async function resolveStaticMetadata( async function resolveStaticMetadata(
modules: AppDirModules, modules: AppDirModules,
props: SegmentProps props: SegmentProps,
segment: string
): Promise<StaticMetadata> { ): Promise<StaticMetadata> {
const { metadata } = modules const { metadata } = modules
if (!metadata) return null if (!metadata) return null
const [icon, apple, openGraph, twitter] = await Promise.all([ const [icon, apple, openGraph, twitter] = await Promise.all([
collectStaticImagesFiles(metadata, props, 'icon'), collectStaticImagesFiles(metadata, props, 'icon', segment),
collectStaticImagesFiles(metadata, props, 'apple'), collectStaticImagesFiles(metadata, props, 'apple'),
collectStaticImagesFiles(metadata, props, 'openGraph'), collectStaticImagesFiles(metadata, props, 'openGraph'),
collectStaticImagesFiles(metadata, props, 'twitter'), collectStaticImagesFiles(metadata, props, 'twitter'),
...@@ -639,7 +649,11 @@ async function collectMetadata({ ...@@ -639,7 +649,11 @@ async function collectMetadata({
route += `/${modType}` route += `/${modType}`
} }
const staticFilesMetadata = await resolveStaticMetadata(tree[2], props) const staticFilesMetadata = await resolveStaticMetadata(
tree[2],
props,
tree[0]
)
const metadataExport = mod ? getDefinedMetadata(mod, props, { route }) : null const metadataExport = mod ? getDefinedMetadata(mod, props, { route }) : null
metadataItems.push([metadataExport, staticFilesMetadata]) metadataItems.push([metadataExport, staticFilesMetadata])
...@@ -769,11 +783,16 @@ async function resolveMetadataItemsImpl( ...@@ -769,11 +783,16 @@ async function resolveMetadataItemsImpl(
? segmentParam.paramName ? segmentParam.paramName
: parentOptionalCatchAllParamName : parentOptionalCatchAllParamName
console.group(
`resolveMetadataItemsImpl - ${segment} - createServerParamsForMetadata`,
currentParams
)
const params = createServerParamsForMetadata( const params = createServerParamsForMetadata(
currentParams, currentParams,
optionalCatchAllParamName, optionalCatchAllParamName,
isRuntimePrefetchable isRuntimePrefetchable
) )
console.groupEnd()
const props: SegmentProps = isPage ? { params, searchParams } : { params } const props: SegmentProps = isPage ? { params, searchParams } : { params }
await collectMetadata({ await collectMetadata({
......
...@@ -512,6 +512,7 @@ function makeGetDynamicParamFromSegment( ...@@ -512,6 +512,7 @@ function makeGetDynamicParamFromSegment(
fallbackRouteParams: OpaqueFallbackRouteParams | null, fallbackRouteParams: OpaqueFallbackRouteParams | null,
optimisticRouting: boolean optimisticRouting: boolean
): GetDynamicParamFromSegment { ): GetDynamicParamFromSegment {
console.log('makeGetDynamicParamFromSegment', interpolatedParams)
return function getDynamicParamFromSegment(loaderTree: LoaderTree) { return function getDynamicParamFromSegment(loaderTree: LoaderTree) {
const [segment, , , staticSiblings] = loaderTree const [segment, , , staticSiblings] = loaderTree
const segmentParam = getSegmentParam(segment) const segmentParam = getSegmentParam(segment)
......
...@@ -865,6 +865,7 @@ async function createComponentTreeInternal( ...@@ -865,6 +865,7 @@ async function createComponentTreeInternal(
} else { } else {
// If we are passing params to a server component Page we need to track // If we are passing params to a server component Page we need to track
// their usage in case the current render mode tracks dynamic API usage. // their usage in case the current render mode tracks dynamic API usage.
console.log('segment', segment)
const params = createServerParamsForServerSegment( const params = createServerParamsForServerSegment(
currentParams, currentParams,
optionalCatchAllParamName, optionalCatchAllParamName,
...@@ -1048,6 +1049,7 @@ async function createComponentTreeInternal( ...@@ -1048,6 +1049,7 @@ async function createComponentTreeInternal(
) )
} }
} else { } else {
console.log('---------------------\nsegment', segment)
const params = createServerParamsForServerSegment( const params = createServerParamsForServerSegment(
currentParams, currentParams,
optionalCatchAllParamName, optionalCatchAllParamName,
......
...@@ -225,6 +225,7 @@ export class StagedRenderingController { ...@@ -225,6 +225,7 @@ export class StagedRenderingController {
| RenderStage.Runtime | RenderStage.Runtime
| RenderStage.Dynamic | RenderStage.Dynamic
) { ) {
console.log(`----------- ${RenderStage[stage]} -----------`)
// If we're already at the target stage or beyond, do nothing. // If we're already at the target stage or beyond, do nothing.
// (this can happen e.g. if sync IO advanced us to the dynamic stage) // (this can happen e.g. if sync IO advanced us to the dynamic stage)
if (stage <= this.currentStage) { if (stage <= this.currentStage) {
......
...@@ -254,6 +254,16 @@ export function createServerParamsForServerSegment( ...@@ -254,6 +254,16 @@ export function createServerParamsForServerSegment(
isRuntimePrefetchable isRuntimePrefetchable
) )
case 'request': case 'request':
console.log('createServerParamsForServerSegment', {
asyncApiPromises: !!workUnitStore.asyncApiPromises,
validationSamples: !!workUnitStore.validationSamples,
underlyingParams,
fallbackParams: workUnitStore.fallbackParams,
hasFallbackRouteParams: hasFallbackRouteParams(
underlyingParams,
workUnitStore.fallbackParams
),
})
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// Semantically we only need the dev tracking when running in `next dev` // Semantically we only need the dev tracking when running in `next dev`
// but since you would never use next dev with production NODE_ENV we use this // but since you would never use next dev with production NODE_ENV we use this
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment