From 4026c1080d4bb780ba342b5181b3128b193b0511 Mon Sep 17 00:00:00 2001 From: Mike Mollick Date: Thu, 20 Jun 2024 17:18:02 -0400 Subject: [PATCH 1/2] fix: remove throw from body of setTimeout --- src/apiClient.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/apiClient.ts b/src/apiClient.ts index 40113d10..76c6fbb7 100644 --- a/src/apiClient.ts +++ b/src/apiClient.ts @@ -148,7 +148,6 @@ export default class APIClient { const controller: AbortController = new AbortController(); const timeout = setTimeout(() => { controller.abort(); - throw new NylasSdkTimeoutError(req.url, this.timeout); }, this.timeout); try { @@ -187,6 +186,10 @@ export default class APIClient { return response; } catch (error) { + if (error instanceof Error && error.name === "AbortError") { + throw new NylasSdkTimeoutError(req.url, this.timeout); + } + clearTimeout(timeout); throw error; } From 5ae32767cd11b23db99028b17060a635f18b58d8 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 8 Jul 2024 15:50:30 -0400 Subject: [PATCH 2/2] Update src/apiClient.ts Co-authored-by: Mostafa Rashed <17770919+mrashed-dev@users.noreply.github.com> --- src/apiClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apiClient.ts b/src/apiClient.ts index 76c6fbb7..744d7626 100644 --- a/src/apiClient.ts +++ b/src/apiClient.ts @@ -186,7 +186,7 @@ export default class APIClient { return response; } catch (error) { - if (error instanceof Error && error.name === "AbortError") { + if (error instanceof Error && error.name === 'AbortError') { throw new NylasSdkTimeoutError(req.url, this.timeout); }