Skip to content

Conversation

@dimkl
Copy link
Contributor

@dimkl dimkl commented Mar 29, 2024

Description

Error resolved by returning an empty string or null instead of trying to decode the jwt property from the response data. After this fix an token.getRawString() will return an empty string and session.getToken() will return null on Network failure and when request fails and browser is offline.

Current error message example:

Error: ClerkJS: Token refresh failed (error='Cannot read properties of null (reading 'jwt')')

Backport: #3035

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:

@dimkl dimkl requested a review from nikosdouvlis March 29, 2024 10:37
@dimkl dimkl self-assigned this Mar 29, 2024
@dimkl dimkl requested a review from a team as a code owner March 29, 2024 10:37
@changeset-bot
Copy link

changeset-bot bot commented Mar 29, 2024

🦋 Changeset detected

Latest commit: 2580596

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

This PR includes changesets to release 13 packages
Name Type
@clerk/clerk-js Patch
@clerk/types Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/backend Patch
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/localizations Patch
@clerk/nextjs Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/clerk-sdk-node Patch
@clerk/themes 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

@dimkl
Copy link
Contributor Author

dimkl commented Mar 29, 2024

!snapshot

@dimkl dimkl force-pushed the fix/token-refresh-failed-nul branch from eb4f14c to 2063010 Compare March 29, 2024 11:41
@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/backend 0.38.4-snapshot.veb4f14c
@clerk/chrome-extension 0.6.17-snapshot.veb4f14c
@clerk/clerk-js 4.70.7-snapshot.veb4f14c
@clerk/clerk-expo 0.20.12-snapshot.veb4f14c
@clerk/fastify 0.6.37-snapshot.veb4f14c
gatsby-plugin-clerk 4.4.39-snapshot.veb4f14c
@clerk/localizations 1.26.17-snapshot.veb4f14c
@clerk/nextjs 4.29.10-snapshot.veb4f14c
@clerk/clerk-react 4.30.8-snapshot.veb4f14c
@clerk/remix 3.2.1-snapshot.veb4f14c
@clerk/clerk-sdk-node 4.13.12-snapshot.veb4f14c
@clerk/themes 1.7.11-snapshot.veb4f14c
@clerk/types 3.62.2-snapshot.veb4f14c

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

npm i @clerk/backend@0.38.4-snapshot.veb4f14c --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@0.6.17-snapshot.veb4f14c --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@4.70.7-snapshot.veb4f14c --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@0.20.12-snapshot.veb4f14c --save-exact

@clerk/fastify

npm i @clerk/fastify@0.6.37-snapshot.veb4f14c --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@4.4.39-snapshot.veb4f14c --save-exact

@clerk/localizations

npm i @clerk/localizations@1.26.17-snapshot.veb4f14c --save-exact

@clerk/nextjs

npm i @clerk/nextjs@4.29.10-snapshot.veb4f14c --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@4.30.8-snapshot.veb4f14c --save-exact

@clerk/remix

npm i @clerk/remix@3.2.1-snapshot.veb4f14c --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@4.13.12-snapshot.veb4f14c --save-exact

@clerk/themes

npm i @clerk/themes@1.7.11-snapshot.veb4f14c --save-exact

@clerk/types

npm i @clerk/types@3.62.2-snapshot.veb4f14c --save-exact

@dimkl dimkl force-pushed the fix/token-refresh-failed-nul branch from 2063010 to deb94e2 Compare March 29, 2024 11:47
@dimkl
Copy link
Contributor Author

dimkl commented Mar 29, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/backend 0.38.4-snapshot.vdeb94e2
@clerk/chrome-extension 0.6.17-snapshot.vdeb94e2
@clerk/clerk-js 4.70.7-snapshot.vdeb94e2
@clerk/clerk-expo 0.20.12-snapshot.vdeb94e2
@clerk/fastify 0.6.37-snapshot.vdeb94e2
gatsby-plugin-clerk 4.4.39-snapshot.vdeb94e2
@clerk/localizations 1.26.17-snapshot.vdeb94e2
@clerk/nextjs 4.29.10-snapshot.vdeb94e2
@clerk/clerk-react 4.30.8-snapshot.vdeb94e2
@clerk/remix 3.2.1-snapshot.vdeb94e2
@clerk/clerk-sdk-node 4.13.12-snapshot.vdeb94e2
@clerk/themes 1.7.11-snapshot.vdeb94e2
@clerk/types 3.62.2-snapshot.vdeb94e2

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

npm i @clerk/backend@0.38.4-snapshot.vdeb94e2 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@0.6.17-snapshot.vdeb94e2 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@4.70.7-snapshot.vdeb94e2 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@0.20.12-snapshot.vdeb94e2 --save-exact

@clerk/fastify

npm i @clerk/fastify@0.6.37-snapshot.vdeb94e2 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@4.4.39-snapshot.vdeb94e2 --save-exact

@clerk/localizations

npm i @clerk/localizations@1.26.17-snapshot.vdeb94e2 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@4.29.10-snapshot.vdeb94e2 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@4.30.8-snapshot.vdeb94e2 --save-exact

@clerk/remix

npm i @clerk/remix@3.2.1-snapshot.vdeb94e2 --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@4.13.12-snapshot.vdeb94e2 --save-exact

@clerk/themes

npm i @clerk/themes@1.7.11-snapshot.vdeb94e2 --save-exact

@clerk/types

npm i @clerk/types@3.62.2-snapshot.vdeb94e2 --save-exact

…failure

Error resolved by returning an empty string or null instead of trying to
decode the `jwt` property from the response data. After this fix an
`token.getRawString()` will return an empty string and  `session.getToken()`
will return `null`  on Network failure and when request fails and browser
is offline.

Current error message example:
```
Error: ClerkJS: Token refresh failed (error='Cannot read properties of null (reading 'jwt')')
```
@dimkl dimkl force-pushed the fix/token-refresh-failed-nul branch from deb94e2 to 2580596 Compare March 29, 2024 11:59
Copy link
Member

@brkalow brkalow left a comment

Choose a reason for hiding this comment

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

👏

@dimkl dimkl merged commit cd2bf9d into release/v4 Mar 29, 2024
@dimkl dimkl deleted the fix/token-refresh-failed-nul branch March 29, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants