Skip to content

Patch adonis5-jwt to fix jwt errors spamming - #163

Merged
SpecialAro merged 2 commits into
ferdium:mainfrom
SpecialAro:patch-adonis5-jwt
Mar 28, 2026
Merged

Patch adonis5-jwt to fix jwt errors spamming#163
SpecialAro merged 2 commits into
ferdium:mainfrom
SpecialAro:patch-adonis5-jwt

Conversation

@SpecialAro

Copy link
Copy Markdown
Member

Errors keeps spamming on the server that have to do with an issue with adonis5-jwt dependency.

This PR fixes it.

[03:40:34.808] ERROR (ferdium-server/26932): insert into jwt_tokens (created_at, expires_at, name, refresh_token, refresh_token_expires_at, token, type, user_id) values ('2026-03-28 03:40:34', NULL, 'JWT Access Token', '0473567a9c4eccaf5bcb5c5574163e330a2e08ac259eaeb9a602c9552dc9b181', '2026-04-07 04:40:34', '48d6abcf5c087eaaa6b784ad74ac02ef3661205fe334faa095973c441b766ba4', 'jwt_token', 1) - SQLITE_CONSTRAINT: UNIQUE constraint failed: jwt_tokens.token
    err: {
      "type": "Error",
      "message": "insert into jwt_tokens (created_at, expires_at, name, refresh_token, refresh_token_expires_at, token, type, user_id) values ('2026-03-28 03:40:34', NULL, 'JWT Access Token', '0473567a9c4eccaf5bcb5c5574163e330a2e08ac259eaeb9a602c9552dc9b181', '2026-04-07 04:40:34', '48d6abcf5c087eaaa6b784ad74ac02ef3661205fe334faa095973c441b766ba4', 'jwt_token', 1) - SQLITE_CONSTRAINT: UNIQUE constraint failed: jwt_tokens.token",
      "stack":
          Error: insert into jwt_tokens (created_at, expires_at, name, refresh_token, refresh_token_expires_at, token, type, user_id) values ('2026-03-28 03:40:34', NULL, 'JWT Access Token', '0473567a9c4eccaf5bcb5c5574163e330a2e08ac259eaeb9a602c9552dc9b181', '2026-04-07 04:40:34', '48d6abcf5c087eaaa6b784ad74ac02ef3661205fe334faa095973c441b766ba4', 'jwt_token', 1) - SQLITE_CONSTRAINT: UNIQUE constraint failed: jwt_tokens.token
      "errno": 19,
      "code": "SQLITE_CONSTRAINT",
      "status": 500
    }

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR patches the adonis5-jwt dependency to prevent repeated JWT persistence failures (e.g., SQLITE_CONSTRAINT: UNIQUE constraint failed: jwt_tokens.token) and adds coverage to ensure concurrent token issuance yields unique tokens.

Changes:

  • Add a pnpm patch for adonis5-jwt to add uniqueness to generated JWTs (JTI) and retry on duplicate-persistence errors.
  • Add a per-token nonce to JWT payloads in the UserController’s signup/login/new-token flows.
  • Add functional tests validating concurrent login and new-token requests return distinct tokens.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/functional/api/register.spec.ts Adds functional tests asserting concurrent requests produce unique JWTs.
app/Controllers/Http/UserController.ts Adds a random nonce to JWT payloads to ensure token uniqueness across rapid requests.
patches/adonis5-jwt@1.1.7.patch Patches the JWT guard to add JTI and retry persistence on unique-constraint collisions.
package.json Registers the pnpm patched dependency.
pnpm-lock.yaml Records the patch metadata and patched resolution for adonis5-jwt.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/functional/api/register.spec.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SpecialAro
SpecialAro merged commit f5cc3d9 into ferdium:main Mar 28, 2026
1 check passed
@SpecialAro
SpecialAro deleted the patch-adonis5-jwt branch March 28, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants