Skip to content

Commit

Permalink
Pare back to only necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Jan 4, 2024
1 parent 48d0b35 commit 4bfa5ee
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/api/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,20 @@ export class AtpAgent {
this.session = undefined

if (e instanceof XRPCError && e.error) {
// `ExpiredToken` and `InvalidToken` are handled by the `this._refreshSession`
if (['AuthMissing', 'InvalidDID'].includes(e.error)) {
/*
* `ExpiredToken` and `InvalidToken` are handled in
* `this_refreshSession`, and emit an `expired` event there.
*
* `AuthMissing` is a respose from `getSession`, and happens AFTER the
* initial `expired` event is sent. If we handle that here, we'll
* double-emit `expired`.
*
* `InvalidDID` is emit above, and should be handled here.
*
* Everything else is unexpected.
*/
if (['InvalidDID'].includes(e.error)) {
this._persistSession?.('expired', undefined)
} else {
this._persistSession?.('network-error', undefined)
}
} else {
this._persistSession?.('network-error', undefined)
Expand Down

0 comments on commit 4bfa5ee

Please sign in to comment.