Julián David
Julián David2mo ago

Refresh token issue – Next.js with React Compiler and PPR

Do you think Convex can work with the React Compiler and Next.js using PPR? I’m having an issue with the cookie—it’s not revalidating. I’m using Next.js, Convex auth with Auth.js, PPR, and the React Compiler enabled. Every time the session needs to be refreshed, it doesn’t happen automatically, and I have to reload the browser twice to make it work. I’ve seen similar issues reported in different places, but the suggested solutions haven’t worked for me. If anyone has a hint, I’d appreciate it! I can also give access to the repo, and I’ll find time to create a reproduction example later
7 Replies
Convex Bot
Convex Bot2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
sshader
sshader2mo ago
Do you have any debug logs you can share? (https://labs.convex.dev/auth/debugging) I don't know much about PPR and don't know of folks who have tried it with Convex Auth. However, the logic for attempting to revalidate the cookie should be entirely client side, so I'd expect that part to not be affected
Debugging - Convex Auth
Authentication library for your Convex backend
Julián David
Julián DavidOP2mo ago
thank you @sshader , I see these logs the first time, but if I reload the page, it works.
No description
Julián David
Julián DavidOP2mo ago
and this is from Vercel:
No description
Julián David
Julián DavidOP2mo ago
current middleware:
No description
sshader
sshader2mo ago
Could you also add verbose logging to your middleware? This looks like there's an old token stored in cookies and instead of either logging you out + clearing the cookies or getting a new token, it's doing something else but more logs would help (I also can't tell which of your vercel logs are from refreshing vs. redirects so a little hard for me to tell what's happening here)
Julián David
Julián DavidOP2mo ago
I made a silly mistake in my middleware. The issue is no longer happening 😉

Did you find this page helpful?