Repository: tannerlinsley/react-query (ts)

Issue:
Error state if query is reset while loading
**Describe the bug**
Upon pressing 'reset' on a query while it is already loading, the error state is shown.

**To Reproduce**
Steps to reproduce the behavior:
1. Open react-query dev tools.
2. Click on a query in the list.
3. In the panel that opens, under 'Actions', click 'Reset'.
4. Ordinary loading behaviour should be seen.
5. Now press 'Reset' twice in quick succession.
6. An error state should be seen.

**Expected behavior**
The component should have stayed in the loading state the whole time.

**Screenshots**
Here's a sandbox: [codesandbox.io/s/i8443](https://codesandbox.io/s/i8443). 

Here's a screenshot:
> ![Jan-07-2021 15-37-05](https://user-images.githubusercontent.com/6892123/103911857-7765af00-50fe-11eb-92ac-55dafb3fc9e9.gif)


**Desktop (please complete the following information):**
 - OS: macos
 - Browser: chrome
 - Version: 87.0.4280.88

Let me know if I can help at all!

Pull request description:
fix: stop returning cancelledError on reset during fetch
Fixes #1594.

Tested manually by resetting a query using dev tools while it's refetching. 

Added a test to cover this behaviour.

(My first PR here – happy to make further changes if I've missed anything!)

Patch:
diff --git a/src/core/query.ts b/src/core/query.ts
index 0dd52ed47..6f8610c20 100644
--- a/src/core/query.ts
+++ b/src/core/query.ts
@@ -227,7 +227,7 @@ export class Query<
 
   destroy(): void {
     this.clearGcTimeout()
-    this.cancel()
+    this.cancel({ silent: true })
   }
 
   reset(): void {


Test patch:
diff --git a/src/core/tests/query.test.tsx b/src/core/tests/query.test.tsx
index ab69872a6..baa91aa6c 100644
--- a/src/core/tests/query.test.tsx
+++ b/src/core/tests/query.test.tsx
@@ -282,6 +282,36 @@ describe('query', () => {
     expect(isCancelledError(error)).toBe(true)
   })
 
+  test('should not error if reset while loading', async () => {
+    const key = queryKey()
+
+    const queryFn = jest.fn()
+
+    queryFn.mockImplementation(async () => {
+      await sleep(10)
+      throw new Error()
+    })
+
+    queryClient.fetchQuery(key, queryFn, {
+      retry: 3,
+      retryDelay: 10,
+    })
+
+    // Ensure the query is loading
+    const query = queryCache.find(key)!
+    expect(query.state.status).toBe('loading')
+
+    // Reset the query while it is loading
+    query.reset()
+
+    await sleep(100)
+
+    // The query should
+    expect(queryFn).toHaveBeenCalledTimes(1) // have been called,
+    expect(query.state.error).toBe(null) // not have an error, and
+    expect(query.state.status).toBe('idle') // not be loading any longer
+  })
+
   test('should be able to refetch a cancelled query', async () => {
     const key = queryKey()