Skip to content

Conversation

@cmatheson
Copy link
Collaborator

The ERROR state is meant to indicate terminal errors (like the session being over). authkit-js will not attempt to retrieve new tokens after when in an ERROR state.

Temporary errors (like fetch or tab-lock errors) should not move to the error state. This allows future calls to getAccessToken to attempt to retrieve a new token.

cmatheson added a commit that referenced this pull request Dec 31, 2024
changes:

* avoids initial refresh when user has no session (#61)
* throws error instead of returning stale access tokens when offline
  (#63)

fixes:

* properly exports `OnRefreshResponse` type
@cmatheson cmatheson mentioned this pull request Dec 31, 2024
@cmatheson cmatheson force-pushed the better-fetch-error-handling branch from fbadeb6 to f579f50 Compare December 31, 2024 18:15
The ERROR state is meant to indicate terminal errors (like the session
being over). authkit-js will not attempt to retrieve new tokens after
when in an ERROR state.

Temporary errors (like `fetch` or tab-lock errors) should _not_ move to
the error state. This allows future calls to `getAccessToken` to attempt
to retrieve a new token.
@cmatheson cmatheson force-pushed the better-fetch-error-handling branch from f579f50 to de96d45 Compare December 31, 2024 18:37
@cmatheson cmatheson merged commit e50c0f7 into main Dec 31, 2024
1 check passed
@cmatheson cmatheson deleted the better-fetch-error-handling branch December 31, 2024 18:40
cmatheson added a commit that referenced this pull request Dec 31, 2024
changes:

* avoids initial refresh when user has no session (#61)
* throws error instead of returning stale access tokens when offline
  (#63)

fixes:

* properly exports `OnRefreshResponse` type
Comment on lines +502 to +508
const errorScope = nock("https://api.workos.com")
.post("/user_management/authenticate", {
client_id: "client_123abc",
grant_type: "refresh_token",
})
.times(2)
.replyWithError(new TypeError("Network Error"));
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

cmatheson added a commit that referenced this pull request Dec 31, 2024
changes:

* avoids initial refresh when user has no session (#61)
* throws error instead of returning stale access tokens when offline
  (#63)

fixes:

* properly exports `OnRefreshResponse` type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants