Skip to content

Commit

Permalink
More forgiving spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
natefaubion committed Aug 21, 2021
1 parent 6d9e304 commit 6b688b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Node/WorkerBees.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 6b688b7

Please sign in to comment.