From 082b1843cc7bceaae3bb1c58d29f235cade15b2d Mon Sep 17 00:00:00 2001 From: ericboucher Date: Mon, 21 Oct 2024 16:08:42 +0200 Subject: [PATCH] Update upload-sheet-data.ts --- packages/api/src/utils/uploads/upload-sheet-data.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/api/src/utils/uploads/upload-sheet-data.ts b/packages/api/src/utils/uploads/upload-sheet-data.ts index 6ccda086a..52cc828f1 100644 --- a/packages/api/src/utils/uploads/upload-sheet-data.ts +++ b/packages/api/src/utils/uploads/upload-sheet-data.ts @@ -719,15 +719,18 @@ interface UploadTimeSeriesDataProps { siteTimezone?: boolean; } +const MEMORY_LIMIT = 2048; // 2GB const MAX_MEMORY_USAGE_PERCENT = 80; // Adjust this threshold as needed function checkMemoryUsage() { const used = memoryUsage().heapUsed / 1024 / 1024; const total = memoryUsage().heapTotal / 1024 / 1024; - const usagePercent = (used / total) * 100; + const usagePercent = (used / MEMORY_LIMIT) * 100; if (usagePercent > MAX_MEMORY_USAGE_PERCENT) { - throw new Error(`Memory usage too high: ${usagePercent.toFixed(2)}%`); + console.warn(`Memory usage too high: ${usagePercent.toFixed(2)}%`); + console.warn(`Used: ${used.toFixed(2)}MB, Total: ${total.toFixed(2)}MB`); + // throw new Error(`Memory usage too high: ${usagePercent.toFixed(2)}%`); } }