From d8ec88014087a2120622e9bdb49b8e692c66d13b Mon Sep 17 00:00:00 2001 From: Sam Slotsky Date: Thu, 9 Apr 2020 14:33:35 -0500 Subject: [PATCH] Re-throw abort errors (#85) --- src/v0/gateway.ts | 4 ++++ src/v0/graphqlFetch.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/v0/gateway.ts b/src/v0/gateway.ts index fb07404..63a75ff 100644 --- a/src/v0/gateway.ts +++ b/src/v0/gateway.ts @@ -37,6 +37,10 @@ export function createGateway({ try { resp = await fetch(`${baseUrl()}${path}`, options); } catch (e) { + if (e.name === 'AbortError') { + throw e; + } + if (canRetry) { await wait(attempts ** 2 * 1000); return post(path, body, attempts + 1, init); diff --git a/src/v0/graphqlFetch.ts b/src/v0/graphqlFetch.ts index 88308d3..067f141 100644 --- a/src/v0/graphqlFetch.ts +++ b/src/v0/graphqlFetch.ts @@ -114,6 +114,10 @@ export function createGraphqlFetch({ options.body = JSON.stringify(args); response = await fetch(endpoint(), options); } catch (e) { + if (e.name === 'AbortError') { + throw e; + } + // Retry if (canRetry) { await wait(attempts ** 2 * 1000);