Skip to content

Commit

Permalink
fix: catch axios canceled error
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshvai committed Nov 23, 2023
1 parent e5ddb40 commit 7cbeb3e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions package/src/contexts/messageInputContext/MessageInputContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,10 @@ export const MessageInputProvider = <
const extraData: Partial<FileUpload> = { 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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7cbeb3e

Please sign in to comment.