From 8bc6bd00f17b0d0d8e7c04a38e8907dd49692cbf Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 3 Dec 2024 18:16:08 +0900 Subject: [PATCH] Relax the check for skipping the profiler functions in the stack trace --- src/wasm-memprof.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wasm-memprof.ts b/src/wasm-memprof.ts index 72c7051..ba59250 100644 --- a/src/wasm-memprof.ts +++ b/src/wasm-memprof.ts @@ -506,9 +506,13 @@ export class WMProf { // Skip some internal functions from the stack const shouldSkip = (callSite: NodeJS.CallSite): boolean => { const fileName = callSite.getFileName(); - if (fileName?.includes("wasm-memprof.js")) { + // Skip functions from the profiler itself + // NOTE: The filename might not be "wasm-memprof.js" as is if + // the code is bundled. Thus, we loosely check here. + if (fileName?.includes("wasm-memprof")) { return true; } + // Skip hooked allocator functions const funcName = callSite.getFunctionName(); for (const hook of HOOKED_FUNCTIONS) { if (funcName === `hooked_${hook}`) {