Infinite redirect loop in NextJS development environment
Description
I'm getting this error constantly after logging into an account. This is development environment and running on localhost
Package + Version
- [ ]
@clerk/clerk-js - [ ]
@clerk/clerk-react - [x]
@clerk/nextjs - [ ]
@clerk/remix - [ ]
@clerk/types - [ ]
@clerk/themes - [ ]
@clerk/localizations - [ ]
@clerk/clerk-expo - [ ]
@clerk/backend - [ ]
@clerk/clerk-sdk-node - [ ]
@clerk/shared - [ ]
@clerk/fastify - [ ]
@clerk/chrome-extension - [ ]
gatsby-plugin-clerk - [ ]
build/tooling/chore - [ ] other:
{
"dependencies": {
"@clerk/nextjs": "^4.21.12",
"next": "13.4.7",
}
}
On my windows PC, syncing with the time server solved the issue. It might occur again, but I am good for now
Does anybody encouter it on production app? where use doesn't sync with time server from windows settings? I mean, We developer fixing it on our device but what if it happens same with end users ? Where they didn't sync with time server?
(Mine also fixed with time server sync)
Yikes, you're definitely right about that, there has to be like a workaround around this.
I am using "@clerk/nextjs": "^4.23.2". I have changed the time and time zone and I still getting the same error ... Does anyone have a solutions?
We've noticed. that certain users have bad cookie values which causes the infinite loop.
The cookie name is __client_uat and the bad value is 0 instead of some timestamp like 1692272951
Once we clear this cookie the redirect loops are gone.
Our observation of this cookie is that it gets a bad value when we switch between the subdomains of our app - Production / Staging.
We've noticed. that certain users have bad cookie values which causes the infinite loop.
The cookie name is
__client_uatand the bad value is0instead of some timestamp like1692272951Once we clear this cookie the redirect loops are gone.
Our observation of this cookie is that it gets a bad value when we switch between the subdomains of our app - Production / Staging.
I didn't get this bad value, All I needed was to change the time zone. Thanks for sharing by the way
I am using "@clerk/nextjs": "^4.23.2". I have changed the time and time zone and I still getting the same error ... Does anyone have a solutions?
Which OS are you using If I may ask @emLuc86dev
I"m using Windows 11. I changed my time and time zone. I cleared the cache and cookies and I'm still getting the same error. Then I tried another web browser and still the same... Thanks for your time
El dom, 20 de ago de 2023 1:49 p. m., Timi @.***> escribió:
I am using @.***/nextjs": "^4.23.2". I have changed the time and time zone and I still getting the same error ... Does anyone have a solutions?
Which OS are you using If I may ask?
— Reply to this email directly, view it on GitHub https://github.com/clerkinc/javascript/issues/1436#issuecomment-1685352120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXR5LLQAMTKQI4F4D5HM43XWJE2DANCNFSM6AAAAAAZYYYU6Q . You are receiving this because you commented.Message ID: @.***>
[image: image.png]
El dom, 20 ago 2023 a la(s) 19:07, Emilio Salvia @.***) escribió:
I"m using Windows 11. I changed my time and time zone. I cleared the cache and cookies and I'm still getting the same error. Then I tried another web browser and still the same... Thanks for your time
El dom, 20 de ago de 2023 1:49 p. m., Timi @.***> escribió:
I am using @.***/nextjs": "^4.23.2". I have changed the time and time zone and I still getting the same error ... Does anyone have a solutions?
Which OS are you using If I may ask?
— Reply to this email directly, view it on GitHub https://github.com/clerkinc/javascript/issues/1436#issuecomment-1685352120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXR5LLQAMTKQI4F4D5HM43XWJE2DANCNFSM6AAAAAAZYYYU6Q . You are receiving this because you commented.Message ID: @.***>
Issued at date: Mon Jul 10 2023 19:40:49 GMT+0200 (Central European Summer Time); Current date: Mon Jul 10 2023 19:40:38 GMT+0200 (Central European Summer Time); (reason=token-not-active-yet, token-carrier=cookie)
This is confirming that your clock is out of sync and in the future. Syncing your clock with a time server should resolve this error.
Thank you very much, it turns out that toggling "Set time automatically" and "Set time zone automatically", with synchronizing the time, and properly setting my time zone did the trick.
thanks when i setup then restart computer that okay;
Hi mate I'm having this bug yet... I've tried everything, cleared cookies and cache, changed time and time zone automatically. I deleted the project and created it from scratch and still have the same infinity loop bug....
El lun, 21 ago 2023 a la(s) 09:21, zhou jing @.***) escribió:
Issued at date: Mon Jul 10 2023 19:40:49 GMT+0200 (Central European Summer Time); Current date: Mon Jul 10 2023 19:40:38 GMT+0200 (Central European Summer Time); (reason=token-not-active-yet, token-carrier=cookie)
This is confirming that your clock is out of sync and in the future. Syncing your clock with a time server should resolve this error.
Thank you very much, it turns out that toggling "Set time automatically" and "Set time zone automatically", with synchronizing the time, and properly setting my time zone did the trick.
[image: image] https://user-images.githubusercontent.com/68476321/260267986-2a4edf9f-dee4-436b-9a1b-a48cb9913469.png
thanks when i setup then restart computer that okay;
— Reply to this email directly, view it on GitHub https://github.com/clerkinc/javascript/issues/1436#issuecomment-1686319785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXR5LM5OT3J6BQGIENK4QTXWNOFDANCNFSM6AAAAAAZYYYU6Q . You are receiving this because you were mentioned.Message ID: @.***>
@emLuc86dev maybe this https://github.com/clerkinc/javascript/issues/1566 is the cause of your bug? it also causes infinite loop but for a different reason that the timezone one
I"m using Windows 11. I changed my time and time zone. I cleared the cache and cookies and I'm still getting the same error. Then I tried another web browser and still the same... Thanks for your time El dom, 20 de ago de 2023 1:49 p. m., Timi @.> escribió: … I am using @./nextjs": "^4.23.2". I have changed the time and time zone and I still getting the same error ... Does anyone have a solutions? Which OS are you using If I may ask? — Reply to this email directly, view it on GitHub <#1436 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUXR5LLQAMTKQI4F4D5HM43XWJE2DANCNFSM6AAAAAAZYYYU6Q . You are receiving this because you commented.Message ID: @.***>
I want you to sign out of your app first, so sign out, clear cookies, local storage, session storage, and browsing data for your app. Then change the time and zone, as I screenshot earlier, then try again. One thing I've noticed is to try different devices. You can either host it online to test it or use ngrok. If still that didn't work send you can DM me the project let me take a look
@emLuc86dev maybe this #1566 is the cause of your bug? it also causes infinite loop but for a different reason that the timezone one
Now this one I've not seen before, @emLuc86dev try using the debug mode and share what error you seem to be having
Issued at date: Mon Jul 10 2023 19:40:49 GMT+0200 (Central European Summer Time); Current date: Mon Jul 10 2023 19:40:38 GMT+0200 (Central European Summer Time); (reason=token-not-active-yet, token-carrier=cookie)
This is confirming that your clock is out of sync and in the future. Syncing your clock with a time server should resolve this error.
Thank you very much, it turns out that toggling "Set time automatically" and "Set time zone automatically", with synchronizing the time, and properly setting my time zone did the trick.
thanks when i setup then restart computer that okay;
You're welcome @jokereven
We've noticed. that certain users have bad cookie values which causes the infinite loop.
The cookie name is
__client_uatand the bad value is0instead of some timestamp like1692272951Once we clear this cookie the redirect loops are gone.
Our observation of this cookie is that it gets a bad value when we switch between the subdomains of our app - Production / Staging.
Is your staging using Dev keys from Clerk? If so, we would recommend either:
- using production keys (sharing the user base) for staging so the cookies are the same
- using a second domain and a second, free Production instance for staging to have a limited user base.
I"m using Windows 11. I changed my time and time zone. I cleared the cache and cookies and I'm still getting the same error. Then I tried another web browser and still the same...
Did you add debug: true (see https://github.com/clerkinc/javascript/issues/1436#issuecomment-1668728895)? If so, what were the results of the log?
This error happens after a long time of not using the app. The session token will expire at that time, and a page on the site needs to load to refresh. This is what I've noticed; not sure if it's what's happening.
For me, if I don't use the app for a long time, and then I visit a protected page hoping that I'll be redirected, typically, the error shows up, but at that time, Clerk would have done refresh, and when I reload the page, everything works fine again. I am sure that it's not an issue with my time.
Has anyone else noticed the same thing?
I'm now pretty sure that this is what is happening, at least for me.
The token is usually expired when loading the app after a long time.
Maybe someone else should try it
This issue has been open for nearly 2 months and now encapsulates several different issues from different people, some resolved, some maybe not. In an effort to clean things up a bit, going to close this out. Please do not interpret this as us not caring - we know that this error has been difficult for many, and have been discussing how to improve it internally. Please feel free to open a new issue, ideally with a reproduction, for anyone still encountering this issue!
I am still encountering this issue. syncing the timezone didn't solve the problem
