From 7cbeb3e9a6d2fe37af598e6b042fd3280b398427 Mon Sep 17 00:00:00 2001 From: Santhosh Vaiyapuri Date: Thu, 23 Nov 2023 17:38:51 +0100 Subject: [PATCH] fix: catch axios canceled error --- .../messageInputContext/MessageInputContext.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/src/contexts/messageInputContext/MessageInputContext.tsx b/package/src/contexts/messageInputContext/MessageInputContext.tsx index edf762ba79..59692580c7 100644 --- a/package/src/contexts/messageInputContext/MessageInputContext.tsx +++ b/package/src/contexts/messageInputContext/MessageInputContext.tsx @@ -984,7 +984,10 @@ export const MessageInputProvider = < const extraData: Partial = { thumb_url: response.thumb_url, url: response.file }; setFileUploads(getUploadSetStateAction(id, FileState.UPLOADED, extraData)); } catch (error: unknown) { - if (error instanceof Error && error.name === 'AbortError') { + if ( + error instanceof Error && + (error.name === 'AbortError' || error.name === 'CanceledError') + ) { // nothing to do uploadAbortControllerRef.current.delete(file.name); return; @@ -1081,7 +1084,10 @@ export const MessageInputProvider = < setImageUploads(newImageUploads); } } catch (error) { - if (error instanceof Error && error.name === 'AbortError') { + if ( + error instanceof Error && + (error.name === 'AbortError' || error.name === 'CanceledError') + ) { // nothing to do uploadAbortControllerRef.current.delete(filename); return;