From ce3fc0d92c336c92885770885f5d9647fb278222 Mon Sep 17 00:00:00 2001 From: Josh Long Date: Mon, 3 Aug 2026 08:24:10 -0400 Subject: [PATCH] fix(worker): pass function name worker function invokation. --- src/Pool.js | 2 +- src/worker.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Pool.js b/src/Pool.js index ab842738..e2aa40fc 100644 --- a/src/Pool.js +++ b/src/Pool.js @@ -166,7 +166,7 @@ Pool.prototype.exec = function (method, params, options) { return resolver.promise; } else if (typeof method === "function") { // send stringified function and function arguments to worker - return this.exec("run", [String(method), params], options); + return this.exec("run", [String(method), params, method.name], options); } else { throw new TypeError('Function or string expected as argument "method"'); } diff --git a/src/worker.js b/src/worker.js index c3f967ef..cea6b10f 100644 --- a/src/worker.js +++ b/src/worker.js @@ -127,9 +127,14 @@ worker.methods = {}; * @param {Array} [args] Function arguments * @returns {*} */ -worker.methods.run = function run(fn, args) { +worker.methods.run = function run(fn, args, fnName) { var f = new Function('return (' + fn + ').apply(this, arguments);'); f.worker = publicWorker; + Object.defineProperty(f, "name", { + value: fnName || "user defined function", + configurable: true, + }); + return f.apply(f, args); };