Skip to content

Commit c2a4b49

Browse files
authored
Merge pull request #440 from devtron-labs/fix/resource-tree-deleting
fix: aborted exception handling
2 parents 03010a9 + 742c7bc commit c2a4b49

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/Api.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ function fetchInTime<T = object>(
204204
options.abortControllerRef.current = new AbortController()
205205
}
206206

207+
// Note: This is not catered in case abortControllerRef is passed since
208+
// the API is rejected with abort signal from line 202
209+
// FIXME: Remove once signal is removed
207210
reject({
208211
code: 408,
209212
errors: [{ code: 408, internalMessage: 'Request cancelled', userMessage: 'Request Cancelled' }],
@@ -224,6 +227,7 @@ function fetchInTime<T = object>(
224227
if (err instanceof ServerErrors) {
225228
throw err
226229
} else {
230+
// FIXME: Can be removed once signal is removed
227231
throw new ServerErrors({
228232
code: 408,
229233
errors: [

src/Common/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ export const API_STATUS_CODES = {
511511
UNAUTHORIZED: 401,
512512
PERMISSION_DENIED: 403,
513513
NOT_FOUND: 404,
514+
REQUEST_TIMEOUT: 408,
514515
EXPECTATION_FAILED: 417,
515516
UNPROCESSABLE_ENTITY: 422,
516517
LOCKED: 423,

src/Common/Helper.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import regexIcon from '@Icons/ic-regex.svg'
4949
import pullRequest from '@Icons/ic-pull-request.svg'
5050
import tagIcon from '@Icons/ic-tag.svg'
5151
import { SourceTypeMap } from '@Common/Common.service'
52+
import { getIsRequestAborted } from './Api'
5253

5354
export function showError(serverError, showToastOnUnknownError = true, hideAccessError = false) {
5455
if (serverError instanceof ServerErrors && Array.isArray(serverError.errors)) {
@@ -71,7 +72,7 @@ export function showError(serverError, showToastOnUnknownError = true, hideAcces
7172
}
7273
})
7374
} else {
74-
if (serverError.code !== 403 && serverError.code !== 408) {
75+
if (serverError.code !== 403 && serverError.code !== 408 && !getIsRequestAborted(serverError)) {
7576
Sentry.captureException(serverError)
7677
}
7778

0 commit comments

Comments
 (0)