From c64232cca1d5226bdf899c4a3b617f8f38571cc1 Mon Sep 17 00:00:00 2001 From: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com> Date: Tue, 17 Sep 2024 20:07:07 +0530 Subject: [PATCH] fix(bg/openPayments): handle `invalid_continuation` on disconnect --- src/background/services/openPayments.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/background/services/openPayments.ts b/src/background/services/openPayments.ts index 9fc24ea8..53551106 100644 --- a/src/background/services/openPayments.ts +++ b/src/background/services/openPayments.ts @@ -628,7 +628,7 @@ export class OpenPaymentsService { try { await this.client!.grant.cancel(grantContinuation); } catch (error) { - if (isInvalidClientError(error)) { + if (isInvalidClientError(error) || isInvalidContinuationError(error)) { // key already removed from wallet return; } @@ -787,6 +787,11 @@ export const isInvalidClientError = (error: any) => { return error.status === 400 && error.code === 'invalid_client'; }; +export const isInvalidContinuationError = (error: any) => { + if (!isOpenPaymentsClientError(error)) return false; + return error.status === 401 && error.code === 'invalid_continuation'; +}; + // RESOURCE SERVER error. Create outgoing payment and create quote can fail // with: `Signature validation error: could not find key in list of client keys` export const isSignatureValidationError = (error: any) => {