adrianhajdin / threads

Develop Threads, Next.js 13 app that skyrocketed to 100 million sign-ups in less than 5 days, and dethroned giants like Twitter, ChatGPT, and TikTok to become the fastest-growing app ever!

Home Page:https://threads-psi.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clerk: Clock skew detected

PrtHub opened this issue · comments

Error: Clerk: Clock skew detected. This usually means that your system clock is inaccurate. Clerk will continuously try to issue new tokens, as the existing ones will be treated as "expired" due to clock skew.

To resolve this issue, make sure your system's clock is set to the correct time (e.g. turn off and on automatic time synchronization).


JWT cannot be used prior to not before date claim (nbf). Not before date: Thu, 28 Sep 2023 06:35:34 GMT; Current date: Thu, 28 Sep 2023 06:35:04 GMT; (reason=token-not-active-yet, token-carrier=cookie)

I get this error all the time, I usually speed up the timer and stop this error but I think it is something clerk is trying to fix

I have the same problem when I try to login with Clerk authentication.

In my case I'm running WSL2 with Ubuntu in my Windows 11 machine. When I checked the time in the ubuntu terminal (where the nextjs app is running) it was out of sync with Windows so I had to update it manually with the following command sudo hwclock -s. After that the problem was solved. I read that it's a common problem when the computer go to sleep, the Ubuntu clock gets out of sync with Windows.

Encountered the same Problem on WSL2, computer was also put to sleep before . sudo hwclock -s did not fix it for me, only restarting the server a second time does it for me.

`
1 of 1 unhandled error
Server Error
Error: Clerk: Clock skew detected. This usually means that your system clock is inaccurate. Clerk will continuously try to issue new tokens, as the existing ones will be treated as "expired" due to clock skew.

To resolve this issue, make sure your system's clock is set to the correct time (e.g. turn off and on automatic time synchronization).


JWT cannot be used prior to not before date claim (nbf). Not before date: Sat, 07 Oct 2023 17:50:14 GMT; Current date: Sat, 07 Oct 2023 17:50:07 GMT; (reason=token-not-active-yet, token-carrier=cookie)

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
assertClockSkew
node_modules@clerk\nextjs\dist\esm\server\authMiddleware.js (173:10)
assertClockSkew
node_modules@clerk\nextjs\dist\esm\server\authMiddleware.js (73:6)
async adapter
node_modules\next\dist\esm\server\web\adapter.js (150:19)
async runWithTaggedErrors
file:///C:/Users/xxx/Desktop/nextjs13/node_modules/next/dist/server/web/sandbox/sandbox.js (96:24)
async DevServer.runMiddleware
file:///C:/Users/xxx/Desktop/nextjs13/node_modules/next/dist/server/next-server.js (962:24)
async DevServer.runMiddleware
file:///C:/Users/xxx/Desktop/nextjs13/node_modules/next/dist/server/dev/next-dev-server.js (250:28)
async DevServer.handleCatchallMiddlewareRequest
file:///C:/Users/xxx/Desktop/nextjs13/node_modules/next/dist/server/next-server.js (1051:22)
async DevServer.handleRequestImpl
file:///C:/Users/xxx/Desktop/nextjs13/node_modules/next/dist/server/base-server.js (736:32)`

If you are using WSL with windows, it will be slightly off.

ISSUE:
image

SOLUTION:
If you go into your Ubuntu WSL terminal, the command below will fix the issue:

sudo apt install ntpupdate && sudo ntpdate pool.ntp.org

RESULTS:
9 Oct 06:46:10 ntpdate[31661]: step time server 129.250.35.250 offset +148.127650 sec
Restart your server then it should work as seen below:
image
After Signing in and accessing secured page:
image

Checking home page after signing in:
image

I dont have wsl setup in my computer still getting this problem

If you are using Windows 11 and encountering an error, you can attempt to resolve it by following these steps:

  • Click on "Settings" in the Windows Start menu.
  • Navigate to "Time & Language" within the Settings menu.
  • Select "Date & Time" from the Time & Language options.
  • Click on "Additional Settings."
  • Finally, select "Sync now" to synchronize your system's date and time settings.

image

This fixed my issue, You can give it a try.

I am using Windows 11 the latest 22H2, I am only set to ON in this setting date & time
image

If you are using Windows 11 and encountering an error, you can attempt to resolve it by following these steps:

* Click on **"Settings"** in the Windows Start menu.

* Navigate to **"Time & Language"** within the Settings menu.

* Select **"Date & Time"** from the Time & Language options.

* Click on **"Additional Settings."**

* Finally, select **"Sync now"** to synchronize your system's date and time settings.

image

This fixed my issue, You can give it a try.

I've just tried that, including restarting the system. This error just started happening suddenly, the app was opening normally and I didn't change any date and time settings. I also checked my project on Clerk and everything seems fine on there. What else could it be?

If you are using Windows 11 and encountering an error, you can attempt to resolve it by following these steps:

* Click on **"Settings"** in the Windows Start menu.

* Navigate to **"Time & Language"** within the Settings menu.

* Select **"Date & Time"** from the Time & Language options.

* Click on **"Additional Settings."**

* Finally, select **"Sync now"** to synchronize your system's date and time settings.

image

This fixed my issue, You can give it a try.

I've tried that but unfortunately it's still happening. I didn't mess with my date and time settings, the project was opening normally and that issue just suddenly started happening! This is so odd. What else could that be?

I've tried fixing the time on settings but unfortunately it's still happening. I didn't mess with my date and time settings, the project was opening normally and that issue just suddenly started happening! This is so odd. What else could that be?

If you are using Windows 11 and encountering an error, you can attempt to resolve it by following these steps:

  • Click on "Settings" in the Windows Start menu.
  • Navigate to "Time & Language" within the Settings menu.
  • Select "Date & Time" from the Time & Language options.
  • Click on "Additional Settings."
  • Finally, select "Sync now" to synchronize your system's date and time settings.

image

This fixed my issue, You can give it a try.

this work, thanks

Well i fix it but i dont rly know how.

  1. Update windows install all updates.
  2. https://www.worldtimeserver.com/atomic-clock/
  • ping google.com
  • ping 8.8.8.8
  • ping time.windows.com
  1. https://www.youtube.com/watch?v=7KFJDFkiaAg

One ot this steps fix my issue in sync time.

In my case I'm running WSL2 with Ubuntu in my Windows 11 machine. When I checked the time in the ubuntu terminal (where the nextjs app is running) it was out of sync with Windows so I had to update it manually with the following command sudo hwclock -s. After that the problem was solved. I read that it's a common problem when the computer go to sleep, the Ubuntu clock gets out of sync with Windows.

Resolved my isssue clearly.
Thanks

If you are using Windows 11 and encountering an error, you can attempt to resolve it by following these steps:

  • Click on "Settings" in the Windows Start menu.
  • Navigate to "Time & Language" within the Settings menu.
  • Select "Date & Time" from the Time & Language options.
  • Click on "Additional Settings."
  • Finally, select "Sync now" to synchronize your system's date and time settings.

image

This fixed my issue, You can give it a try.

thanks a tonn manhh

i can'f fix it. help me pls..
image

You should go to 'Date and time' settings on windows and there 'Sync now' If this doesn't work then , try turning off/on the 'set automatic time' and 'select automatic timezone' for both try turning off/on and try also with sync now :))

On Thu, 30 Nov, 2023, 1:39 pm PhucHung2k1, @.> wrote: i can'f fix it. help me pls.. image.png (view on web) https://github.com/adrianhajdin/threads/assets/124114709/4c96636b-81a6-4260-9d96-02e54e82d4fd — Reply to this email directly, view it on GitHub <#86 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWZGTS5Y5T62AATOHBWQ4D3YHA5NFAVCNFSM6AAAAAA5KONN2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZTGI4DKMRYGU . You are receiving this because you commented.Message ID: @.>

image
it take long time and doesn't work again :((

@FredDaFed sudo apt install ntpupdate && sudo ntpdate pool.ntp.org
this command is not working, showing cannot locate packages for ntpupdate.
So, can you share another way?
for now, what i did to prevent this error is, i just delete my account relogin and use the tokens. and that's how it is working but the problem is till when i need to do like this only??

I am using Mac and facing this error what steps would work ?

Please refer my above instructions , prolly a mismatch btw time in ur system and time in server

I change my localhost:3000 to another option such as localhost3001 and it worked.

Screenshot 2024-01-02 144436
I fixed it by turning everything on as in the picture and clicking "sync now".

If you are mac, you can go to your date and time settings and then check the box for "set date and time automatically" if its and unchecked and uncheck if its checked. This fixed it for me

commented

Found the issue with my system.
My local instance of WSL Ubunbtu has a time lag of an hour.
That's the reason it's getting messed up with the Clerk JWT token thing.

Now, I'm browing net/using ChatGPT to fix the time clock of WSL on my Windows system

commented

My issue resolved. Removed systemd-timesyncd and installed ntp. That synced my WSL time with the correct network time and I got rid of the error.

Does anyone know how to handle this error accurately on the application level? Does it appear in production?

Under the mac OS. I tried this command to force to sync my machine time.

sudo sntp -Ss time.asia.apple.com

Then issued fixed, for my case.

Well i fix it but i dont rly know how.

  1. Update windows install all updates.
  2. https://www.worldtimeserver.com/atomic-clock/
  • ping google.com
  • ping 8.8.8.8
  • ping time.windows.com
  1. https://www.youtube.com/watch?v=7KFJDFkiaAg

One ot this steps fix my issue in sync time.

this actually fixed it for me

commented

If you are using WSL with windows, it will be slightly off.

ISSUE: image

SOLUTION: If you go into your Ubuntu WSL terminal, the command below will fix the issue:

sudo apt install ntpupdate && sudo ntpdate pool.ntp.org

RESULTS: 9 Oct 06:46:10 ntpdate[31661]: step time server 129.250.35.250 offset +148.127650 sec Restart your server then it should work as seen below: image After Signing in and accessing secured page: image

Checking home page after signing in: image

You should to update your command to make it works on terminal:

your command: sudo apt install ntpupdate && sudo ntpdate pool.ntp.org

correct command: sudo apt install ntpdate && sudo ntpdate pool.ntp.org

Now, it works for me! Thank you.

Update your system time like here https://time.is/, I updated and fixed the error

If you are in Windows 11 try these steps

1: Sync your time from the settings
2: Restart your Pc
3: Run your app
4: Open the inspect panel in the browser
5: Switch to storage
6: Delete all from localhost

inspect

WORKING SOLUTION FOR WINDOWS :

Go To Services -> Windows Time -> Right click -> Start
Again Go to Services -> Windows Time -> Right Click -> properties -> startup type -> automatic and then apply .

After that Go to Settings -> Date and Time -> Sync

If you are using Windows 11 and encountering an error, you can attempt to resolve it by following these steps:

  • Click on "Settings" in the Windows Start menu.
  • Navigate to "Time & Language" within the Settings menu.
  • Select "Date & Time" from the Time & Language options.
  • Click on "Additional Settings."
  • Finally, select "Sync now" to synchronize your system's date and time settings.

image

This fixed my issue, You can give it a try.

it's work! thank

turning the "Set time Automatically" off worked for me :)

I have this issue on Vercel... I deleted a user in Clerk auth, it was stored in the cookie and tried to use the cookie for logging in.

I get this error all the time, I usually speed up the timer and stop this error but I think it is something clerk is trying to fix

hey @MatthewAraujo , could you please tell what do you mean by "speed up the timer"?

If you are using Windows 11 and encountering an error, you can attempt to resolve it by following these steps:

  • Click on "Settings" in the Windows Start menu.
  • Navigate to "Time & Language" within the Settings menu.
  • Select "Date & Time" from the Time & Language options.
  • Click on "Additional Settings."
  • Finally, select "Sync now" to synchronize your system's date and time settings.

image

This fixed my issue, You can give it a try.

thank you very much, It works for me! 💖