fix: use lazy promise on getCartCount to defer cookies() execution#1880
Conversation
This fixes 500 error: needs to bail out of prerendering at this point because it used cookies() Without the lazy promise, the getCartCount() is immediately executed, and calls cookies(). With lazy promise, the getCartCount() execution is deferred, until await/then is used.
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
migueloller
left a comment
There was a problem hiding this comment.
Thanks!
Looking at this makes me wonder if we should handle this in VIBES at some point, where we take the approach of accepting functions and we turn them into lazy promises 🤔
What/Why?
This fixes 500 error:
Without the lazy promise, the
getCartCount()is immediately executed, and callscookies()on the Header.With lazy promise, the
getCartCount()execution is deferred, untilawait/thenis used.Testing
This bug was only reproducible if we reverted the temporary fix commit on the
soul/makeswift/integrationbranch. See this deployment.Makeswift pages are PPRed correctly instead of being server-rendered
No 500 error logs:
