Skip to content

Commit

Permalink
Reset signing token in error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewBarba committed Nov 21, 2024
1 parent d164c4a commit 99adfed
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/apns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class ApnsClient extends EventEmitter {
maxConcurrentStreams: 100,
})
this._token = null
this.on(Errors.expiredProviderToken, () => this._resetSigningToken())
}

send(notification: Notification) {
Expand Down Expand Up @@ -124,6 +123,11 @@ export class ApnsClient extends EventEmitter {
response: responseError as ApnsResponseError,
})

// Reset signing token if expired
if (error.reason === Errors.expiredProviderToken) {
this._token = null
}

// Emit specific and generic errors
this.emit(error.reason, error)
this.emit(Errors.error, error)
Expand Down Expand Up @@ -156,8 +160,4 @@ export class ApnsClient extends EventEmitter {

return token
}

private _resetSigningToken() {
this._token = null
}
}

0 comments on commit 99adfed

Please sign in to comment.