From 86094cc054f061048d8b3b8707f2bef885b17fcb Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Thu, 20 Apr 2023 11:19:12 +0530 Subject: [PATCH] fix: fixed issue where cancelling requests was throwing an error (#146) --- .../src/providers/ReduxStore/slices/collections/actions.js | 6 ++++++ packages/bruno-electron/src/ipc/network/index.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index 4b3e3722..e95059cd 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -122,6 +122,12 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => { response: null }) ); + + if(err && err.message === "Error invoking remote method 'send-http-request': Error: Request cancelled") { + console.log('>> request cancelled'); + return; + } + console.log('>> sending request failed'); console.log(err); toast.error(err ? err.message : 'Something went wrong!'); diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index e65f6737..1c9b0ace 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -202,6 +202,12 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => { // need to convey the error to the UI // and need not be always a network error deleteCancelToken(cancelTokenUid); + + if (axios.isCancel(error)) { + let error = new Error("Request cancelled"); + error.isCancel = true; + return Promise.reject(error); + } if(error.response) { return {