From 6b688b79920920fe0b3df418bf227f75f373c54e Mon Sep 17 00:00:00 2001 From: Nathan Faubion Date: Sat, 21 Aug 2021 09:15:19 -0700 Subject: [PATCH] More forgiving spawn --- src/Node/WorkerBees.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Node/WorkerBees.js b/src/Node/WorkerBees.js index 3812c48..2b4135d 100644 --- a/src/Node/WorkerBees.js +++ b/src/Node/WorkerBees.js @@ -9,7 +9,10 @@ exports.spawnImpl = function(left, right, worker, options, cb) { var thread; var requirePath = res.filePath.replace(/\\/g, "\\\\"); var jsEval = res.export - ? 'require("' + requirePath + '").' + res.export + '.spawn()' + ? [ + 'var worker = require("' + requirePath + '").' + res.export + ';', + 'worker.spawn ? worker.spawn() : worker();' + ].join('\n') : 'require("' + requirePath + '")'; try { thread = new workerThreads.Worker(jsEval, {