fix: use lazy promise for searchParams to defers execution#1901
fix: use lazy promise for searchParams to defers execution#1901fikrikarim wants to merge 1 commit intocanaryfrom
Conversation
This is needed to fix 500 error: Route /[locale]/search needs to bail out of prerendering at this point because it used `await searchParams`, `searchParams.then`, or similar.
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| const searchParams = PLazy.from(() => pageProps.searchParams); | ||
| const props = { searchParams }; |
There was a problem hiding this comment.
If we're seeing problems with searchParams similar to cookies I think that we might need a different approach here...
Having to use a lazy promise here feels wrong to me. In particular, Search should be dynamic always.
There was a problem hiding this comment.
I agree with @migueloller on this. Search is being rendered dynamically though.
There was a problem hiding this comment.
Search should be dynamic always.
Wait, with this change, search is still dynamic. This change just defers the searchParams execution to component that await the function.
But I agree with the general sentiment though. This is a landmine. I don't want developers to think about this quirk while developing Catalyst.
I'll close this PR for now while we search for a better solution.
|
Is this only happening when running the makeswift integration? |
Yeah. It's a race condition that happens and it's really a problem with the streamable pattern and the way React implements "postpone". We might need to do this lazy evaluation but that might need to happen at the VIBES API layer so Catalyst isn't doing this. Or we might need to figure out a different approach. I should probably set up a repro in the suspense-patterns repo so we can explore ideas |

What/Why?
Use lazy promise on
searchParamsto defers execution.This is needed to fix the 500 error:
Testing
We had the same problem with
cookies()on theHeader: #1880