From dee80bc6a1e8e61515372118f16742a0b84bca31 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Thu, 4 Apr 2024 15:48:26 +0200 Subject: [PATCH] use native `AbortController` --- config/FixJSDOMEnvironment.js | 2 +- .../persisted-queries/__tests__/persisted-queries.test.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config/FixJSDOMEnvironment.js b/config/FixJSDOMEnvironment.js index 9077731b9b0..dbbf9d3356f 100644 --- a/config/FixJSDOMEnvironment.js +++ b/config/FixJSDOMEnvironment.js @@ -14,7 +14,7 @@ class FixJSDOMEnvironment extends JSDOMEnvironment { // and setting AbortController breaks PersistedQueryLink tests, which may // indicate a memory leak // this.global.fetch = fetch; - // this.global.AbortController = AbortController; + this.global.AbortController = AbortController; } } diff --git a/src/link/persisted-queries/__tests__/persisted-queries.test.ts b/src/link/persisted-queries/__tests__/persisted-queries.test.ts index 32d75fe5136..e970af26d6f 100644 --- a/src/link/persisted-queries/__tests__/persisted-queries.test.ts +++ b/src/link/persisted-queries/__tests__/persisted-queries.test.ts @@ -573,7 +573,11 @@ describe("failure path", () => { variables, }).subscribe({ complete }) ); - + // fetch-mock holds a history of all options it has been called with + // that includes the `signal` option, which (with the native `AbortController`) + // has a reference to the `Request` instance, which will somehow reference our + // hash object + fetchMock.resetHistory(); await expect(hashRefs[0]).toBeGarbageCollected(); } );