Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: fn running on worker thread can't resolve Reference #237

Open
far11ven opened this issue Dec 16, 2021 · 0 comments
Open

Comments

@far11ven
Copy link

far11ven commented Dec 16, 2021

For My example below:

var Parallel = require('paralleljs');
var _ = require('lodash');

let data = {
"a":{"id":1},
"b":{"id":2},
"c":{"id":3},
"d":{"id":4}
};

for(let i in data){

const p = new Parallel(data[i]);
p.spawn(test)
.then(function (data) {
    console.log("iv",_.capitalize('hello'))
    const documentProcessingData = ["DATA_MODEL_1","DATA_MODEL_2", "DATA_MODEL_3"];

    documentProcessingData.forEach((curr,index)=>{
    const aiProjectProcessing = new Parallel(curr);
    aiProjectProcessing.spawn(dmdPrcosessing) .then(function (data) {
        console.log("Finished", data);
    })
})

});

}

function test(dmd){
console.log("hello",dmd);
console.log("ii", .capitalize('hello')) //can't resolve "" lodash here
return dmd
}

function dmdPrcosessing(val){

console.log("iii", _.capitalize('hello')) //can't resolve "_" lodash here
var start = new Date().getTime();
var end = start;
var waitingTime = (Math.random() * (10000 - 5000) + 5000);
console.log("waitingTime ",waitingTime);

while(end < start + waitingTime){
  end = new Date().getTime();

}
return val;
}

I get the following error:

undefined:3
console.log("ii", _.capitalize('hello'))
^

ReferenceError: _ is not defined
at dmdPrcosessing (eval at (D:\Workspace\Speed Measurement Comparision\node_modules\paralleljs\lib\eval.js:7:5), :3:24)
at process.eval (eval at (D:\Workspace\Speed Measurement Comparision\node_modules\paralleljs\lib\eval.js:7:5), :13:3)
at process.emit (events.js:314:20)
at emit (internal/child_process.js:877:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)

Is there a better way to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant