Replies: 4 comments 3 replies
-
A Worker in BullMQ is not a thread, however, you can use a sandboxed processor, in this case, the worker will run in an isolated process and then it will not block your main process: https://docs.bullmq.io/guide/workers/sandboxed-processors |
Beta Was this translation helpful? Give feedback.
-
Hi, thank you so much for the clarification! That explains a lot. The Problem now is, that i just cannot get this to work as shown in the example files - this is the error i get: 26s 9:18:11:502 Cannot find module './dist/helper/lod2/worker/intersectionWorker.js'
Require stack:
- /home/user/git/projectRoot/node_modules/bullmq/dist/cjs/classes/child-processor.js
- /home/user/git/projectRoot/node_modules/bullmq/dist/cjs/classes/master.js
undefined can the problem lay here in my tsconfig?: {
"compilerOptions": {
"target": "es2017",
"lib": [
"es2019"
],
"module": "ESNext",
"rootDir": "src",
"moduleResolution": "node",
"outDir": "./dist",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": true,
"skipLibCheck": true
}
} in my app.ts i initialize the worker like so:
what is weird is that when i change the location of the worker to something definitely wrong i get:
so that means that my problem is probably not that i have set a wrong filename but rather something related to bullmq / ts ? if someone has any idea how i could fix that issue, it would be great to hear! Thank you so much! |
Beta Was this translation helpful? Give feedback.
-
hi, thanks for your reply, i have read the link you posted, and changed my tsconfig to match the one provided in the repository (https://github.com/taskforcesh/bullmq-typescript):
and the package.json to:
it took a while to make everything else work accordingly ;) but it builds and starts without any error now.
i did follow the github example to set up the worker. if you have any other idea what i could check or do to make this work i am very happy to hear from you :)! EDIT: "use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const writeHeight_1 = require("./writeHeight");
function default_1(job) {
return __awaiter(this, void 0, void 0, function* () {
console.log("##################################INSIDE WORKER");
const coordinates = job.data.coordinatesList;
const folder = job.data.workingfolder;
console.log(folder, coordinates[0]);
yield (0, writeHeight_1.writeHeight)(coordinates, folder);
});
}
exports.default = default_1; |
Beta Was this translation helpful? Give feedback.
-
Hi, i did manage to get a littlebit further - by i have no idea what...
any idea what that means? |
Beta Was this translation helpful? Give feedback.
-
Hi there, i am starting to get along with bullmq, but run into a problem where a bullmq child seems to lock my main thread in nodejs.
i have an app.ts wich basically looks like this: (there is also a function to get the data from the bull stack, but that seems to work just fine..)
then there is a worker wich looks basically like that:
inside getLOD2Data() is an async function wich also takes some time. it looks like this:
so here comes my trouble: inside this writeBuildingFoundationToCityJson() function i need to calculate millions of points. and to not block the whole thread i thought its a good idea to also use a bullmq worker to let this run and not block everything else. but it still does, like i would not have used a worker.
the writeBuildingFoundationToCityJson() function looks like this:
and the intersection Worker Looks like this:
i have marked in the last worker where the whole thing gets blocked / unresponsive.
What is the problem here - is it that i have two workers within each other? or am i not seeing something else?
if anyone has an idea what i am doing wrong please let me know!!
I hope this is not a too long question, but i just cannot figure out what s happening here. :/
Thanks a lot!!
Beta Was this translation helpful? Give feedback.
All reactions