clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
952 stars 210 forks source link

getToken function returning stale tokens for latest NextJS 13 App Beta #923

Closed zackdotcomputer closed 1 year ago

zackdotcomputer commented 1 year ago

Package + Version

Version:

@clerk/nextjs@4.11.7
@next@13.2.4

Browser/OS

Running on Ubuntu (in WSL) with NextJS 13 app-beta. Issue is server-side.

Description

  1. Having followed the Supabase integration instructions on a NextJs App-Beta app, I am using a custom getToken template to get a signed Supabase token for making API requests.
  2. Using await getToken({ template: "supabase" }) for the first time in a session produces a valid JWT token valid for a minute.
  3. However, using that same command later in the same session produces that same JWT token, meaning that after a minute the call produces an expired token that will be rejected.
  4. Calling await getToken() always produces a valid token. It refreshes automatically.

I had thought this would be related to this commit from @SokratisVidros, but rewinding to 4.11.0 does not appear to fix the issue and forcing <4.11.0 does not appear to work with the latest verisons of Node (18.15) and Next (13.2.4). Instead, it looks like this change is related to something Next has changed since 13.2.3 because using the latest Clerk against that version of Next works as intended.

I think the action-item here is to isolate the change that Next has made since that point release and either respond to it with a local code-change for Clerk or file an issue with Next for them to respond to it. I have been able to narrow down the release that caused the issue through binary search, but could use a hand at this point isolating the cause and moving a fix forward since the list of changes in this version is very long.

clerk-cookie commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

clerk-cookie commented 1 year ago

This issue was closed because it has been stalled for 10 days with no activity.

clerk-cookie commented 1 week ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.