Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): Add more error reasons for refresh token query param #4193

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

anagstef
Copy link
Member

@anagstef anagstef commented Sep 19, 2024

Description

This PR extracts more error reasons to be set on __clerk_refresh query param, instead of falling back to unexpected-refresh-error.

New error codes are:

  • missing-api-client
  • missing-session-token
  • missing-refresh-token
  • session-token-decode-failed
  • fetch-network-error

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented Sep 19, 2024

🦋 Changeset detected

Latest commit: 51c436a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@clerk/backend Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/tanstack-start Patch
@clerk/testing Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@anagstef anagstef self-assigned this Sep 19, 2024
@anagstef anagstef marked this pull request as ready for review September 19, 2024 12:26
@anagstef
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @anagstef - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 1.3.7-snapshot.v150a390
@clerk/backend 1.13.3-snapshot.v150a390
@clerk/chrome-extension 1.3.9-snapshot.v150a390
@clerk/clerk-js 5.22.4-snapshot.v150a390
@clerk/elements 0.15.5-snapshot.v150a390
@clerk/clerk-expo 2.2.15-snapshot.v150a390
@clerk/express 0.1.4-snapshot.v150a390
@clerk/fastify 1.0.46-snapshot.v150a390
@clerk/localizations 3.0.5-snapshot.v150a390
@clerk/nextjs 5.6.1-snapshot.v150a390
@clerk/clerk-react 5.9.2-snapshot.v150a390
@clerk/remix 4.2.30-snapshot.v150a390
@clerk/clerk-sdk-node 5.0.43-snapshot.v150a390
@clerk/shared 2.8.2-snapshot.v150a390
@clerk/tanstack-start 0.4.6-snapshot.v150a390
@clerk/testing 1.3.4-snapshot.v150a390
@clerk/themes 2.1.31-snapshot.v150a390
@clerk/types 4.21.1-snapshot.v150a390

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/clerk-sdk-node

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

// To perform a token refresh, apiClient must be defined.
assertApiClient(options.apiClient);
} catch (err: any) {
throw { errors: [{ code: RefreshTokenErrorReason.MissingApiClient, message: err?.message || '' }] };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the mix between single error and errors array? I've only seen single errors, not multiple, in your code below 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LekoArts an errors array is returned on API errors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just refactored this, to be clearer.

@anagstef
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @anagstef - the snapshot version command generated the following package versions:

Package Version
@clerk/astro 1.3.7-snapshot.v51c436a
@clerk/backend 1.13.3-snapshot.v51c436a
@clerk/chrome-extension 1.3.9-snapshot.v51c436a
@clerk/clerk-js 5.22.4-snapshot.v51c436a
@clerk/elements 0.15.5-snapshot.v51c436a
@clerk/clerk-expo 2.2.15-snapshot.v51c436a
@clerk/express 0.1.4-snapshot.v51c436a
@clerk/fastify 1.0.46-snapshot.v51c436a
@clerk/localizations 3.0.5-snapshot.v51c436a
@clerk/nextjs 5.6.1-snapshot.v51c436a
@clerk/clerk-react 5.9.2-snapshot.v51c436a
@clerk/remix 4.2.30-snapshot.v51c436a
@clerk/clerk-sdk-node 5.0.43-snapshot.v51c436a
@clerk/shared 2.8.2-snapshot.v51c436a
@clerk/tanstack-start 0.4.6-snapshot.v51c436a
@clerk/testing 1.3.4-snapshot.v51c436a
@clerk/themes 2.1.31-snapshot.v51c436a
@clerk/types 4.21.1-snapshot.v51c436a

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/clerk-sdk-node

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants