From 99bca6dcd2fae5d5459d5456ddb030ea0829362d Mon Sep 17 00:00:00 2001 From: Leon Klingele Date: Sat, 8 Feb 2025 09:41:01 +0100 Subject: [PATCH] fix: infinity fetch retry on invalid or expired access token Fixes https://github.com/spotify-api/spotify-api.js/issues/218. --- src/Client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index 0f4954f..ebfd0ec 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -212,9 +212,10 @@ export class Client { error.response.data?.error?.message == "Invalid access token" || // @ts-expect-error - Token can be expired. (error.response.data?.error?.message == "The access token expired" && this.refreshMeta) - ) + ) { await this.refreshFromMeta(); - else throw new SpotifyAPIError(error); + return; + } else throw new SpotifyAPIError(error); return this.fetch(url, options); }