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(clerk-js): Remove session cookie when signing out and onBeforeSetActive #3371

Merged
merged 7 commits into from
May 16, 2024

Conversation

octoper
Copy link
Member

@octoper octoper commented May 13, 2024

Description

Problem:

Right now when signing out on Next.js with app router, there is a chance that you will get an error as we are clearing the app router cache before removing the session cookie.

Solution:

The solution is to move the removal of the session cookie before clearing the app router cache.

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 May 13, 2024

🦋 Changeset detected

Latest commit: c469a32

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

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo 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

@octoper
Copy link
Member Author

octoper commented May 13, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/chrome-extension 1.0.9-snapshot.v40b4e54
@clerk/clerk-js 5.2.5-snapshot.v40b4e54
@clerk/clerk-expo 1.1.1-snapshot.v40b4e54
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.4.0-snapshot.v40b4e54

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

npm i @clerk/chrome-extension@1.0.9-snapshot.v40b4e54 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.5-snapshot.v40b4e54 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.1-snapshot.v40b4e54 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.4.0-snapshot.v40b4e54 --save-exact

@octoper
Copy link
Member Author

octoper commented May 13, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/chrome-extension 1.0.9-snapshot.v3595faf
@clerk/clerk-js 5.2.5-snapshot.v3595faf
@clerk/clerk-expo 1.1.1-snapshot.v3595faf
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.4.0-snapshot.v3595faf

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

npm i @clerk/chrome-extension@1.0.9-snapshot.v3595faf --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.5-snapshot.v3595faf --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.1-snapshot.v3595faf --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.4.0-snapshot.v3595faf --save-exact

@octoper
Copy link
Member Author

octoper commented May 13, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/chrome-extension 1.0.9-snapshot.vb1a12ac
@clerk/clerk-js 5.2.5-snapshot.vb1a12ac
@clerk/clerk-expo 1.1.1-snapshot.vb1a12ac
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.4.0-snapshot.vb1a12ac
@clerk/nextjs 5.0.9-snapshot.vb1a12ac

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

npm i @clerk/chrome-extension@1.0.9-snapshot.vb1a12ac --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.5-snapshot.vb1a12ac --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.1-snapshot.vb1a12ac --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.4.0-snapshot.vb1a12ac --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.9-snapshot.vb1a12ac --save-exact

@octoper
Copy link
Member Author

octoper commented May 14, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/chrome-extension 1.0.9-snapshot.v5ac0a48
@clerk/clerk-js 5.2.5-snapshot.v5ac0a48
@clerk/clerk-expo 1.1.1-snapshot.v5ac0a48
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/localizations 2.4.0-snapshot.v5ac0a48
@clerk/nextjs 5.0.9-snapshot.v5ac0a48

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

npm i @clerk/chrome-extension@1.0.9-snapshot.v5ac0a48 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.2.5-snapshot.v5ac0a48 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.1-snapshot.v5ac0a48 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/localizations

npm i @clerk/localizations@2.4.0-snapshot.v5ac0a48 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.9-snapshot.v5ac0a48 --save-exact

@octoper octoper force-pushed the vaggelis.fix/auth-state-not-updated-after-sign-out branch from 5ac0a48 to 3019c67 Compare May 15, 2024 10:18
@octoper
Copy link
Member Author

octoper commented May 15, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/backend 1.1.5-snapshot.v58e76d6
@clerk/chrome-extension 1.0.10-snapshot.v58e76d6
@clerk/clerk-js 5.3.1-snapshot.v58e76d6
@clerk/elements 0.4.2-snapshot.v58e76d6
@clerk/clerk-expo 1.1.2-snapshot.v58e76d6
@clerk/express 0.0.8-snapshot.v58e76d6
@clerk/fastify 1.0.7-snapshot.v58e76d6
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/nextjs 5.0.10-snapshot.v58e76d6
@clerk/clerk-react 5.0.6-snapshot.v58e76d6
@clerk/remix 4.0.8-snapshot.v58e76d6
@clerk/clerk-sdk-node 5.0.7-snapshot.v58e76d6
@clerk/shared 2.1.1-snapshot.v58e76d6
@clerk/testing 1.0.5-snapshot.v58e76d6

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

npm i @clerk/backend@1.1.5-snapshot.v58e76d6 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@1.0.10-snapshot.v58e76d6 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.3.1-snapshot.v58e76d6 --save-exact

@clerk/elements

npm i @clerk/elements@0.4.2-snapshot.v58e76d6 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@1.1.2-snapshot.v58e76d6 --save-exact

@clerk/express

npm i @clerk/express@0.0.8-snapshot.v58e76d6 --save-exact

@clerk/fastify

npm i @clerk/fastify@1.0.7-snapshot.v58e76d6 --save-exact

gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.10-snapshot.v58e76d6 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.0.6-snapshot.v58e76d6 --save-exact

@clerk/remix

npm i @clerk/remix@4.0.8-snapshot.v58e76d6 --save-exact

@clerk/clerk-sdk-node

npm i @clerk/clerk-sdk-node@5.0.7-snapshot.v58e76d6 --save-exact

@clerk/shared

npm i @clerk/shared@2.1.1-snapshot.v58e76d6 --save-exact

@clerk/testing

npm i @clerk/testing@1.0.5-snapshot.v58e76d6 --save-exact

@octoper octoper force-pushed the vaggelis.fix/auth-state-not-updated-after-sign-out branch from 5ac9520 to cf12ff3 Compare May 15, 2024 13:23
@octoper
Copy link
Member Author

octoper commented May 15, 2024

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
gatsby-plugin-clerk 5.0.0-beta.45
@clerk/nextjs 5.0.11-snapshot.vcf12ff3

Tip: Use the snippet copy button below to quickly install the required packages.
gatsby-plugin-clerk

npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@5.0.11-snapshot.vcf12ff3 --save-exact

@octoper octoper changed the title fix(nextjs): Auth state not updated correctly after sign out for App router fix(clerk-js): Remove session cookie when signing out and onBeforeSetActive May 15, 2024
@octoper octoper marked this pull request as ready for review May 15, 2024 13:33
Copy link
Member

@nikosdouvlis nikosdouvlis left a comment

Choose a reason for hiding this comment

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

Nice one @octoper 👏🏻
I will test a little bit more, add a few unit tests and I'll merge right after

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.

👏

@nikosdouvlis nikosdouvlis force-pushed the vaggelis.fix/auth-state-not-updated-after-sign-out branch from b4beda6 to c469a32 Compare May 16, 2024 01:17
@nikosdouvlis nikosdouvlis merged commit 1fdd436 into main May 16, 2024
10 checks passed
@nikosdouvlis nikosdouvlis deleted the vaggelis.fix/auth-state-not-updated-after-sign-out branch May 16, 2024 02:04
@clerk-cookie clerk-cookie mentioned this pull request May 16, 2024
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.

None yet

4 participants