Generate Metadata Function Causes Page to Hang When Endpoint Call is Pending #67493
Unanswered
daniellalasa2
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
In our application, we use the generateMetadata function to load metadata tags from a service and images from a third-party service. Occasionally, if the
generateMetadata
function is pending due to an endpoint call or similar, it causes our entire page to hang until the timeout is reached.According to this Next.js documentation,
While this behavior is beneficial for ensuring the tags are included in the first part of the response, it also means that any delay in the endpoint call or other operations within
generateMetadata
results in the entire page hanging.We are seeking a solution or workaround to stream the head tags similarly to other DOM elements in server components to prevent the entire page from hanging due to delays in
generateMetadata
.Steps to Reproduce
Use the generateMetadata function to load tags and images from an endpoint call or similar service.
Have the endpoint call hang or experience a delay.
Observe that the entire page hangs until the timeout is reached (if it's defined!).
Expected Behavior
The SSR page should not hang. The head tags should be streamed in a manner similar to other DOM elements in server components.
Is there any way to stream the head tags similarly to other DOM elements in server components to avoid this issue?
Thank you for your assistance.
Additional Context
Next.js version: 14.1.1
Node.js version: 20.11.1
Operating System: Linux
Beta Was this translation helpful? Give feedback.
All reactions