From d0de4de2d5e14355f95e10f04928247db0423621 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 29 Jul 2026 13:30:49 +0700 Subject: [PATCH] refactor: remove uploadConcurrency from config Effective concurrency derived from bot pool size. Chunked-storage backpressure now uses botPool.getEffectiveConcurrency(). Co-Authored-By: Claude Opus 5 (1M context) --- src/env.ts | 2 -- src/utils/chunked-storage.ts | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/env.ts b/src/env.ts index b8485e1..d19a854 100644 --- a/src/env.ts +++ b/src/env.ts @@ -12,7 +12,6 @@ interface AppConfig { rateLimitWindowMs: number; rateLimitMaxRequests: number; trustProxy: boolean; - uploadConcurrency: number; batchMaxItems: number; batchMaxSizeBytes: number; maxRequestBodyBytes: number; @@ -105,7 +104,6 @@ export const config: AppConfig = { rateLimitWindowMs: parseNumber(process.env.RATE_LIMIT_WINDOW_MS, 60000), rateLimitMaxRequests: parseNumber(process.env.RATE_LIMIT_MAX_REQUESTS, 150), trustProxy: process.env.TRUST_PROXY === 'true', - uploadConcurrency: parseNumber(process.env.UPLOAD_CONCURRENCY, 8), batchMaxItems: parseNumber(process.env.BATCH_MAX_ITEMS, 20), batchMaxSizeBytes: parseNumber(process.env.BATCH_MAX_SIZE_BYTES, 500 * 1024 * 1024), maxRequestBodyBytes: parseNumber(process.env.MAX_REQUEST_BODY_BYTES, 2 * 1024 * 1024 * 1024), diff --git a/src/utils/chunked-storage.ts b/src/utils/chunked-storage.ts index 4a6ff57..dce3c74 100644 --- a/src/utils/chunked-storage.ts +++ b/src/utils/chunked-storage.ts @@ -125,7 +125,7 @@ export const uploadFileInTelegramChunks = async (input: { // Backpressure: if too many chunks are in-flight, wait for one to // finish before reading more — prevents unbounded memory growth. - if (inFlight.size >= config.uploadConcurrency * 2) { + if (inFlight.size >= botPool.getEffectiveConcurrency() * 2) { await Promise.race(inFlight); // Yield microtask to let .finally() run and remove from inFlight await new Promise((resolve) => setTimeout(resolve, 0));