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

feat(nextjs): Clock skew error message #1661

Merged
merged 4 commits into from
Sep 1, 2023
Merged

Conversation

BRKalow
Copy link
Member

@BRKalow BRKalow commented Aug 30, 2023

Type of change

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

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

Description

  • npm test runs as expected.
  • npm run build runs as expected.

Attempt to detect clock skew in development based on the requestState. If detected, we log a helpful error message.

Example output:

Error: Clerk: Clock skew detected. This usually means that your server's system clock is inaccurate. Clerk will continuously try to issue new tokens, as the existing ones will be treated as "expired" due to clock skew.

To resolve this issue, make sure your system's clock is set to the correct time (e.g. turn off and on automatic time synchronization).

---

JWT cannot be used prior to not before date claim (nbf). Not before date: Wed Aug 30 2023 13:18:40 GMT-0500 (Central Daylight Time); Current date: Wed Aug 30 2023 13:17:56 GMT-0500 (Central Daylight Time); (reason=token-not-active-yet, token-carrier=cookie)

related to JS-675

@changeset-bot
Copy link

changeset-bot bot commented Aug 30, 2023

🦋 Changeset detected

Latest commit: 26af835

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

This PR includes changesets to release 6 packages
Name Type
@clerk/backend Patch
@clerk/nextjs Patch
@clerk/fastify Patch
gatsby-plugin-clerk Patch
@clerk/remix Patch
@clerk/clerk-sdk-node 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

Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

✅ Great news! Jit hasn't found any security issues in your PR. Good Job! 🏆

@BRKalow BRKalow marked this pull request as ready for review August 30, 2023 18:59
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.

This makes sense to me!

return;
}

if (requestState.reason === 'token-not-active-yet') {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@nikosdouvlis I would have to import from the dist, what's our stance on that?

import { TokenVerificationErrorReason } from '@clerk/backend/dist/types/tokens/errors';

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the requestState.action: TokenVerificationErrorAction.EnsureClockSync ?

packages/nextjs/src/server/errors.ts Outdated Show resolved Hide resolved
@BRKalow
Copy link
Member Author

BRKalow commented Aug 31, 2023

!snapshot

@clerk-cookie
Copy link
Collaborator

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

Package Version
@clerk/backend 0.28.1-snapshot.b493055
@clerk/chrome-extension 0.3.29-snapshot.b493055
@clerk/clerk-js 4.56.2-snapshot.b493055
eslint-config-custom 0.3.0
@clerk/clerk-expo 0.18.20-snapshot.b493055
@clerk/fastify 0.6.5-snapshot.b493055
gatsby-plugin-clerk 4.4.6-snapshot.b493055
@clerk/localizations 1.25.0
@clerk/nextjs 4.23.4-snapshot.b493055
@clerk/clerk-react 4.24.0
@clerk/remix 2.10.1-snapshot.b493055
@clerk/clerk-sdk-node 4.12.4-snapshot.b493055
@clerk/shared 0.22.0
@clerk/themes 1.7.5
@clerk/types 3.50.0

Tip: use the snippet copy button below to quickly install the required packages.

# @clerk/backend
npm i @clerk/backend@0.28.1-snapshot.b493055
# @clerk/chrome-extension
npm i @clerk/chrome-extension@0.3.29-snapshot.b493055
# @clerk/clerk-js
npm i @clerk/clerk-js@4.56.2-snapshot.b493055
# eslint-config-custom
npm i eslint-config-custom@0.3.0
# @clerk/clerk-expo
npm i @clerk/clerk-expo@0.18.20-snapshot.b493055
# @clerk/fastify
npm i @clerk/fastify@0.6.5-snapshot.b493055
# gatsby-plugin-clerk
npm i gatsby-plugin-clerk@4.4.6-snapshot.b493055
# @clerk/localizations
npm i @clerk/localizations@1.25.0
# @clerk/nextjs
npm i @clerk/nextjs@4.23.4-snapshot.b493055
# @clerk/clerk-react
npm i @clerk/clerk-react@4.24.0
# @clerk/remix
npm i @clerk/remix@2.10.1-snapshot.b493055
# @clerk/clerk-sdk-node
npm i @clerk/clerk-sdk-node@4.12.4-snapshot.b493055
# @clerk/shared
npm i @clerk/shared@0.22.0
# @clerk/themes
npm i @clerk/themes@1.7.5
# @clerk/types
npm i @clerk/types@3.50.0

@BRKalow BRKalow merged commit 975412e into main Sep 1, 2023
6 checks passed
@BRKalow BRKalow deleted the brk.feat/clock-skew-error branch September 1, 2023 17:02
@clerk-cookie clerk-cookie mentioned this pull request Sep 1, 2023
@clerk-cookie
Copy link
Collaborator

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

@clerk clerk locked as resolved and limited conversation to collaborators Sep 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants