From ff16a5b01b86e031bef9163e5950687c51b9a58f Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Thu, 4 Jun 2026 08:39:46 +0530 Subject: [PATCH 1/3] Make GraphQL and REST API timeouts configurable via environment variables (Issue #3576) Add centralized timeout configuration allowing customization for different network conditions. Prevents hardcoded timeouts from blocking slow networks or high-load scenarios. Changes: - Create lib/timeout-config.ts with environment-based timeout configuration - GRAPHQL_TIMEOUT_MS: default 8000ms (configurable) - REST_TIMEOUT_MS: default 5000ms (configurable) - DEFAULT_TIMEOUT_MS: default 10000ms (configurable) - Add validation warnings for unreasonably short timeouts Fixes #3576 --- lib/timeout-config.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/timeout-config.ts diff --git a/lib/timeout-config.ts b/lib/timeout-config.ts new file mode 100644 index 000000000..8a96aaa66 --- /dev/null +++ b/lib/timeout-config.ts @@ -0,0 +1,23 @@ +/** + * lib/timeout-config.ts + * + * Centralized timeout configuration for GraphQL and REST API endpoints. + * Allows configuration via environment variables for different network conditions. + */ + +export const TIMEOUT_CONFIG = { + GRAPHQL_TIMEOUT_MS: parseInt(process.env.GRAPHQL_TIMEOUT_MS || '8000', 10), + REST_TIMEOUT_MS: parseInt(process.env.REST_TIMEOUT_MS || '5000', 10), + DEFAULT_TIMEOUT_MS: parseInt(process.env.DEFAULT_TIMEOUT_MS || '10000', 10), +}; + +// Validate timeout values +if (TIMEOUT_CONFIG.GRAPHQL_TIMEOUT_MS < 1000) { + console.warn('GRAPHQL_TIMEOUT_MS < 1000ms may be too short. Recommended minimum: 3000ms'); +} + +if (TIMEOUT_CONFIG.REST_TIMEOUT_MS < 1000) { + console.warn('REST_TIMEOUT_MS < 1000ms may be too short. Recommended minimum: 2000ms'); +} + +export default TIMEOUT_CONFIG; From ea07b31f480983e44f78d59221e51585b0af62b3 Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sat, 6 Jun 2026 13:42:31 +0530 Subject: [PATCH 2/3] Integrate configurable timeouts directly into github.ts Read GITHUB_GRAPHQL_TIMEOUT_MS and GITHUB_REST_TIMEOUT_MS from environment variables with 8000ms and 5000ms defaults respectively, replacing the hardcoded constants. Remove standalone timeout-config.ts as the configuration now lives in the file that uses it. Fixes #3576 --- lib/timeout-config.ts | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 lib/timeout-config.ts diff --git a/lib/timeout-config.ts b/lib/timeout-config.ts deleted file mode 100644 index 8a96aaa66..000000000 --- a/lib/timeout-config.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * lib/timeout-config.ts - * - * Centralized timeout configuration for GraphQL and REST API endpoints. - * Allows configuration via environment variables for different network conditions. - */ - -export const TIMEOUT_CONFIG = { - GRAPHQL_TIMEOUT_MS: parseInt(process.env.GRAPHQL_TIMEOUT_MS || '8000', 10), - REST_TIMEOUT_MS: parseInt(process.env.REST_TIMEOUT_MS || '5000', 10), - DEFAULT_TIMEOUT_MS: parseInt(process.env.DEFAULT_TIMEOUT_MS || '10000', 10), -}; - -// Validate timeout values -if (TIMEOUT_CONFIG.GRAPHQL_TIMEOUT_MS < 1000) { - console.warn('GRAPHQL_TIMEOUT_MS < 1000ms may be too short. Recommended minimum: 3000ms'); -} - -if (TIMEOUT_CONFIG.REST_TIMEOUT_MS < 1000) { - console.warn('REST_TIMEOUT_MS < 1000ms may be too short. Recommended minimum: 2000ms'); -} - -export default TIMEOUT_CONFIG; From 810c49cc0bd47dfa06694df0fa42805ba0c1c416 Mon Sep 17 00:00:00 2001 From: Anshul Jain Date: Mon, 15 Jun 2026 00:35:06 +0530 Subject: [PATCH 3/3] fix: make GraphQL and REST API timeouts configurable via environment variables Replace hardcoded GRAPHQL_TIMEOUT_MS and REST_TIMEOUT_MS constants with environment-variable backed values. Defaults remain 8000ms and 5000ms respectively when GITHUB_GRAPHQL_TIMEOUT_MS and GITHUB_REST_TIMEOUT_MS are not set. This allows operators to tune timeouts for slow networks or high-load scenarios without modifying code. Fixes #3576 --- lib/github.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/github.ts b/lib/github.ts index 859435746..d4dd7d64d 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -29,8 +29,8 @@ interface GitHubRepo { const MAX_RETRIES = 3; const BASE_DELAY_MS = 500; const MAX_RETRY_DELAY_MS = 5000; -const GRAPHQL_TIMEOUT_MS = 8000; // 8s for GraphQL endpoint -const REST_TIMEOUT_MS = 5000; // 5s for REST endpoints +const GRAPHQL_TIMEOUT_MS = parseInt(process.env.GITHUB_GRAPHQL_TIMEOUT_MS || '8000', 10); +const REST_TIMEOUT_MS = parseInt(process.env.GITHUB_REST_TIMEOUT_MS || '5000', 10); const ORG_MEMBER_LIMIT = 100; let currentTokenIndex = 0;