Skip to content

Commit

Permalink
Merge pull request #66 from devtron-labs/feat/timeout-flags
Browse files Browse the repository at this point in the history
feat: timeout flags
  • Loading branch information
AbhishekA1509 authored Jan 4, 2024
2 parents 276660a + adfeee4 commit 4b0c36c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "0.0.48",
"version": "0.0.49",
"description": "Supporting common component library",
"main": "dist/index.js",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions src/Common/Api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ServerErrors } from './ServerError'
import { RequestTimeout, Host, URLS } from './Constants'
import { FALLBACK_REQUEST_TIMEOUT, Host, URLS } from './Constants'
import { ResponseType, APIOptions } from './Types'

const responseMessages = {
Expand Down Expand Up @@ -176,7 +176,9 @@ function fetchInTime(
const controller = new AbortController()
const { signal } = controller
const timeoutPromise: Promise<ResponseType> = new Promise((resolve, reject) => {
let timeout = options?.timeout ? options.timeout : RequestTimeout
const requestTimeout = (window as any)?._env_?.GLOBAL_API_TIMEOUT ?? FALLBACK_REQUEST_TIMEOUT
const timeout = options?.timeout ? options.timeout : requestTimeout

setTimeout(() => {
controller.abort()
reject({
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RegistryTypeDetailType } from "./Types"

export const RequestTimeout = 60000
export const FALLBACK_REQUEST_TIMEOUT = 60000
export const Host = process.env.REACT_APP_ORCHESTRATOR_ROOT

export const DOCUMENTATION_HOME_PAGE = 'https://docs.devtron.ai'
Expand Down

0 comments on commit 4b0c36c

Please sign in to comment.