mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #5893] fix(common): prevent infinite auth refresh retry loop on permanent token failure #5397
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5397
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5893
Author: @danielalanbates
Created: 2/20/2026
Status: 🔄 Open
Base:
main← Head:fix/issue-5885-auth-infinite-retry📝 Commits (1)
f04f3cffix(common): prevent infinite auth refresh retry loop on permanent token failure (#5885)📊 Changes
5 files changed (+147 additions, -23 deletions)
View changed files
📝
packages/hoppscotch-common/src/helpers/backend/GQLClient.ts(+37 -2)📝
packages/hoppscotch-selfhost-web/src/platform/auth/desktop/index.ts(+37 -12)📝
packages/hoppscotch-selfhost-web/src/platform/auth/web/index.ts(+19 -0)📝
packages/hoppscotch-sh-admin/src/helpers/auth.ts(+28 -4)📝
packages/hoppscotch-sh-admin/src/main.ts(+26 -5)📄 Description
Summary
Closes #5885
When a user's refresh token is permanently invalid (expired, rotated, or cookie deleted), the
authExchangein the GQL client enters an infinite retry loop that floods the backend with thousands ofGET /v1/auth/refreshrequests per minute.Root cause
In
GQLClient.ts,refreshAuth()callsplatform.auth.refreshAuthToken()with no retry limit. WhendidAuthError()returnstrue, urql callsrefreshAuth(). If the refresh fails (returnsfalse), urql retries the original GQL operation, which fails auth again, triggering anotherrefreshAuth()— creating an infinite loop. The same pattern exists in thesh-adminauth exchange.Additionally,
refreshToken()in the selfhost-web auth implementations silently swallow errors and have no mechanism to stop retrying.Changes
packages/hoppscotch-common/src/helpers/backend/GQLClient.ts— Added a consecutive failure counter (AUTH_REFRESH_MAX_RETRIES = 3) torefreshAuth(). After 3 consecutive failures, signs the user out instead of retrying indefinitely. Counter resets to 0 on successful refresh or when a new client is created (e.g. after re-login).packages/hoppscotch-selfhost-web/src/platform/auth/web/index.ts— Added matching failure counter torefreshToken()that short-circuits before making HTTP requests after 3 failures. Counter resets on successful refresh or login.packages/hoppscotch-selfhost-web/src/platform/auth/desktop/index.ts— Same protection for the desktop/Tauri auth flow.packages/hoppscotch-sh-admin/src/main.ts— Added retry limit to the admin panel'sauthExchangerefreshAuth().packages/hoppscotch-sh-admin/src/helpers/auth.ts— Added failure counter to the admin panel'srefreshToken().Behavior after fix
Test plan
sh-admin) with the same invalid token scenarioThis PR was created with the assistance of Claude Opus 4.6 by Anthropic. Happy to make any adjustments! Reviewed and submitted by a human.
🤖 Generated with Claude Code
Summary by cubic
Stops the infinite auth refresh loop when the refresh token is permanently invalid. Limits retries to 3, then auto signs out to prevent backend request floods. Fixes #5885.
Written for commit
f04f3cf495. Summary will update on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.