From 1c0ef1edffd27ba87badeaab2b7af480772163ed Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Thu, 29 May 2025 14:30:58 -0300 Subject: [PATCH] add debug memory usage action --- .../debug-memory-usage/debug-memory-usage.mjs | 31 +++++++++++++++++++ components/pipedream_utils/package.json | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 components/pipedream_utils/actions/debug-memory-usage/debug-memory-usage.mjs diff --git a/components/pipedream_utils/actions/debug-memory-usage/debug-memory-usage.mjs b/components/pipedream_utils/actions/debug-memory-usage/debug-memory-usage.mjs new file mode 100644 index 0000000000000..76cbc0c8c2896 --- /dev/null +++ b/components/pipedream_utils/actions/debug-memory-usage/debug-memory-usage.mjs @@ -0,0 +1,31 @@ +import pipedream_utils from "../../pipedream_utils.app.mjs"; +import v8 from "v8"; + +export default { + name: "Debug Memory Usage", + description: "Get memory usage statistics for the current Pipedream workflow.", + key: "pipedream_utils-debug-memory-usage", + version: "0.0.1", + type: "action", + props: { + pipedream_utils, + }, + async run({ $ }) { + function formatBytes(bytes) { + return `${(bytes / 1024 / 1024).toFixed(2)} MB`; + } + + const stats = v8.getHeapStatistics(); + + $.export("$summary", "Successfully exported memory usage statistics"); + + return { + totalHeapSize: formatBytes(stats.total_heap_size), + totalHeapSizeExecutable: formatBytes(stats.total_heap_size_executable), + totalPhysicalSize: formatBytes(stats.total_physical_size), + totalAvailableSize: formatBytes(stats.total_available_size), + usedHeapSize: formatBytes(stats.used_heap_size), + heapSizeLimit: formatBytes(stats.heap_size_limit), + }; + }, +}; diff --git a/components/pipedream_utils/package.json b/components/pipedream_utils/package.json index a18914bc07f7b..6e683ffb5cce5 100644 --- a/components/pipedream_utils/package.json +++ b/components/pipedream_utils/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/pipedream_utils", - "version": "0.0.4", + "version": "0.0.5", "description": "Pipedream Utils Components", "main": "pipedream_utils.app.mjs", "keywords": [