[cache components]: build fail because of request.nextUrl.searchParams
#85412
-
SummaryI am using I got build error in 29 | const title = searchParams.get("title") || siteShortDescription;
30 | const description = searchParams.get("description") || siteDescription; {
digest: 'NEXT_PRERENDER_INTERRUPTED'
}
Error generating OG image: Error: Route /api/og needs to bail out of prerendering at this point because it used nextUrl.searchParams.
at C (turbopack:///[project]/src/app/api/og/route.tsx:27:42)
25 | const { geist, geistMono } = getFontData();
26 |
> 27 | const searchParams = request.nextUrl.searchParams;
| ^
28 |
29 | const title = searchParams.get("title") || siteShortDescription;
30 | const description = searchParams.get("description") || siteDescription; {
digest: 'NEXT_PRERENDER_INTERRUPTED'
}What I do at this point as searchParams is required to genrate og image. Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 21 replies
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
I've found the same issue while testing random things the other day. Ended up fixing it by awaiting connection on top. I've created this repo to replicate the problem. It happens on canary version too: |
Beta Was this translation helpful? Give feedback.



I understand now, a little better at least.
I am adding this to the docs soon, but GET handlers go through the same model as pages in Cache Components.
Here the access to searchParams, causes the handler to "give up" on build time. Your try catch sees that. If you move the access to search params out of the try/catch then you'd stop seeing this issue.
Edit:
x-ref: See also #87732 for the same error with
request.url.Two approaches:
The build succeeds and the route works at runtime. Supp…