convex-js icon indicating copy to clipboard operation
convex-js copied to clipboard

Convex client setAuth wierd behaviour

Open imaai opened this issue 4 months ago • 8 comments

Question before start: Should convex client call fetchAccessToken with forceRefreshToken: true when this is a newly created token that has just been set?

If not there is a wierd behaviour with react client which:

  • First calls fetchAccess with force: false.
  • Then executes second one with force: true.

IMPORTANT: I provide the same token for both of the fetchAccessToken calls.

Image

So according to the blow spec there is something wrong. Because server didn't reject the previous authentication, but client calls the fetchAccessToken with force refresh.

/**
 * An async function returning the JWT-encoded OpenID Connect Identity Token
 * if available.
 *
 * `forceRefreshToken` is `true` if the server rejected a previously
 * returned token, and the client should try to fetch a new one.
 *
 * See {@link ConvexReactClient.setAuth}.
 *
 * @public
 */
export type AuthTokenFetcher = (args: {
  forceRefreshToken: boolean;
}) => Promise<string | null | undefined>;
Image

imaai avatar Jul 17 '25 08:07 imaai