Add more logs, 95%ram alert for GmxMarkets, Proxy retry 2times max
This commit is contained in:
@@ -50,12 +50,13 @@ interface CacheEntry {
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
const CACHE_TTL = 30 * 60 * 1000; // 30 minutes in milliseconds
|
||||
const CACHE_TTL = 60 * 60 * 1000; // 60 minutes in milliseconds (increased from 30 minutes)
|
||||
const marketsCache = new Map<string, CacheEntry>();
|
||||
const MAX_CACHE_SIZE = 5; // Limit cache size to prevent memory issues
|
||||
const MAX_CACHE_SIZE = 20; // Increased cache size to allow more markets data
|
||||
const OPERATION_TIMEOUT = 30000; // 30 seconds timeout for operations
|
||||
|
||||
const MEMORY_WARNING_THRESHOLD = 0.8; // Warn when memory usage exceeds 80%
|
||||
const MEMORY_WARNING_THRESHOLD = 0.85; // Warn when memory usage exceeds 85%
|
||||
const MEMORY_CLEAR_THRESHOLD = 0.95; // Clear cache when memory usage exceeds 95%
|
||||
const MAX_GAS_FEE_USD = 1.5; // Maximum gas fee in USD (1 USDC)
|
||||
|
||||
// Memory monitoring function
|
||||
@@ -68,7 +69,7 @@ function checkMemoryUsage() {
|
||||
console.warn(`⚠️ High memory usage detected: ${(usage * 100).toFixed(1)}% (${Math.round(used.heapUsed / 1024 / 1024)}MB / ${Math.round(total / 1024 / 1024)}MB)`);
|
||||
|
||||
// Clear cache if memory usage is too high
|
||||
if (usage > 0.9) {
|
||||
if (usage > MEMORY_CLEAR_THRESHOLD) {
|
||||
console.warn(`🧹 Clearing markets cache due to high memory usage`);
|
||||
marketsCache.clear();
|
||||
pendingRequests.clear();
|
||||
|
||||
Reference in New Issue
Block a user