From 069c33a033da2a934e98c7eee6b93bbd1b43cd2a Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 12 Aug 2019 20:39:23 +0200 Subject: [PATCH] Fix asyncHook callback interceptor for ProfilingPlugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While writing a custom profiler I ran into the issue that TerserPlugin never called it’s `end` trace. Eventually I tracked it down to the callback function. Instead of being overwritten it was being appended to the end of the function arguments. The callback has to be popped first because the added argument is a wrapper for the original callback. --- lib/debug/ProfilingPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/debug/ProfilingPlugin.js b/lib/debug/ProfilingPlugin.js index 270d6eeb2dc..0ba10aea3d2 100644 --- a/lib/debug/ProfilingPlugin.js +++ b/lib/debug/ProfilingPlugin.js @@ -391,8 +391,8 @@ const makeNewProfiledTapFn = (hookName, tracer, { name, type, fn }) => { id, cat: defaultCategory }); + const callback = args.pop(); fn(...args, (...r) => { - const callback = args.pop(); tracer.trace.end({ name, id,