Questions tagged [worker-thread]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
6 views

Node js threadworker - threadId keep increasing its threadId number

I have a worker_thread, let's say a "Thread manager" in node 18 app that is spawning, let's call them "sub-workers". They do what they do and when finished execution, they send a ...
Svetoslav Trifonov's user avatar
0 votes
0 answers
23 views

NodeJS: WorkerThread or setInterval?

I currently writing a Node app that will launch a bunch of services to check a condition every X seconds and if the result is true, will perform some actions. My first implementation is to instantiate ...
Clint's user avatar
  • 1
-1 votes
1 answer
66 views

How does completablefuture works? [closed]

Need to know the insights of the complete future task without an executor. Here is my sample code CompletableFuture.runAsync(() -> { dosomething(); }); How is this task assigned to the thread? ...
div's user avatar
  • 1
0 votes
0 answers
46 views

Mediapipe thread error in colab F0000 00:00:1704710377.941893 106652 threadpool_pthread_impl.cc:53] Check failed

Can someone please help me fix this issue, I am trying to use mediapipe to computer differences in facial landmarks in two different faces. The code works at first but after several steps it breaks ...
Takuphilchan's user avatar
1 vote
0 answers
70 views

How many threads Node creates per core when using worker threads?

I'm running node js worker threads on MacBook Air M1. There are 8 core. And using PISCINA to create threads. I'm getting 12 threads. Are those for one core or on all 8 core. How do I know if main ...
C'Reality Education's user avatar
0 votes
0 answers
19 views

How to reuse loaded tensorflow model in workerthread in nodejs

I have a tensorflowjs model that I plan to use in nodejs. As the model inference is CPU intensive, I leveraged workerthreads. I do not want to load the model to workerthread every single time before I ...
Doug's user avatar
  • 167
0 votes
1 answer
477 views

How to use ES6 import in worker thread in Node.js?

How to use ES6 import in worker thread? I'm trying to utilize ES6 import syntax in a worker thread in a Node.js environment. However, I'm encountering issues with the import statement. Here's a ...
Amitprj's user avatar
1 vote
0 answers
137 views

How to use mongo connection pool shared with worker threads

I am implementing a nodejs app where I am using worker threads for parallel data processing which requires mongo connection. I am using mongoose here for mongo operation but if I create connection in ...
rahul's user avatar
  • 536
0 votes
0 answers
79 views

Use Piscina and Sharp libraries together for image processing in NestJS

We work on a project with NestJS and GraphQL. In the project we consider ‘image’ module to handle all images in other modules. For serving image we use Controller: @Get(':id') @Header('Cache-Control',...
Mojtaba Hassanzadeh's user avatar
0 votes
0 answers
31 views

Nodejs worker threads shared object

I have an object in the main thread. What's the best way to allow a worker thread to be able to read that object? Note that the object changes multiple times per second.
hmmmm's user avatar
  • 23
1 vote
1 answer
164 views

Singleton worker thread with multiple functions

I am trying to implement a singleton worker thread which has multiple functions which can be requested by the user. I have seen implementations for worker threads using always the same function but I ...
SillyGoose's user avatar
0 votes
1 answer
214 views

Worker threads in Node js

Unable to do axios calls inside worker threads Hi, I have a node js application and I am trying to use worker threads for one of my use case.Inside my worker thread I need to do axios call.I was not ...
Jay supriya miriyala's user avatar
1 vote
1 answer
445 views

Worker Thread, other file than self, cannot find module

I want to have my worker thread as an external file from the runtime file. My current folder structure is src/ > service.ts // my 'main' > thread/ >> test.js inside my service.ts i have ...
Alex Ahlgreen Westergaard's user avatar
0 votes
1 answer
151 views

worker_threads with node.js in nwjs

worker_threads with node.js in nwjs (v0.77.0) crashes without error message Here a list which versions work and where you can find the crash. It started with version v0.69.1 0.77.0 ⛔ 0.76.1 ⛔ ... 0....
Matthias Ma's user avatar
0 votes
1 answer
182 views

only one worker_threads running when i spawned two in nodejs

I have this file analyze-caption-job.ts async function analyzeCaptionJob(): Promise<void> { while (true) { console.log("analyzing!"); await new Promise(f => setTimeout(f, ...
zymeth02's user avatar
0 votes
1 answer
100 views

I have a question about C#'s worker threads

In this code, when you use await Task.Delay(5000);, the line Console.WriteLine("START TestSemaPhoreSlims:ID[" + ids + "]... is executed without any delay. However, when you use Thread....
licenniezh's user avatar
0 votes
1 answer
121 views

Does workerpool declared in multiple routes can still maintain its cpu usage without caring about threshold

I hope to figure out a node.js system with workerpool to handle cpu intensive tasks, but there is something confused me about the cpu usage in multiple routes. A scenario is like this: route1.js: ...
abramhum's user avatar
  • 453
0 votes
2 answers
564 views

How to specify a local file path in Firebase Functions using worker_threads?

I have a firebase function that uses worker_threads to off load some cpu intensive tasks. To initialize the workerThread I give it a local file path to the worker file. But when the firebase function ...
Jordan's user avatar
  • 26
1 vote
0 answers
224 views

Would it be possible to iterate over typescript files in a folder and start a worker thread for each using `ts-node`?

Overview How would one start a worker thread with ts-node? Every attempt that I've made leads to a MODULE_NOT_FOUND error. Various Attempts Currently, I'm attempting to spawn a new worker thread using ...
Arc's user avatar
  • 26
0 votes
1 answer
279 views

Error trying to terminate worker thread using setTimeout()

When trying to terminate a worker thread using setTimeout() I get the following error: node:internal/worker:361 this[kHandle].stopThread(); ^ TypeError: Cannot read properties ...
NoNameIdeas's user avatar
0 votes
0 answers
889 views

NodeJS Worker Threads - message sending before function finished?

I am using a pool of workers to complete some CPU intensive tasks in Node. However, I have a problem in my code below. When a task is first run, everything goes as expected, the pool is created, then ...
jlh77's user avatar
  • 66
0 votes
0 answers
278 views

Parallel processing in Node.js

I'm trying to write a node code that will read multiple json files from directory and insert mapped data into mongodb collection. In order to speed up the process, I have follwed following steps: Put ...
Sudhir's user avatar
  • 837
1 vote
0 answers
320 views

Cannot load data url in Worker Thread

My current worker thread which works fine with file path that tries to console log in that JS file: console.log("hit here"); Now I get the base64 of that file and use Data URL to replace JS ...
Kim Mỹ's user avatar
  • 388
0 votes
0 answers
166 views

Node Worker thread is not working inside api call

I am using node version 16 and following all documented steps. Still worker thread is not working. ` const addPaymentApi = async (req) => { const { payload, adminId } = req.body; logInfo(`...
Ankit Saini's user avatar
1 vote
1 answer
1k views

Node.js- share a heavy variable from parent to worker threads

I want to share a variable between parent and worker threads. The variable is heavy (100+ MB - arrays of JSON data) so if I pass it as an argument or re-read from data source, it drastically increases ...
sprash's user avatar
  • 197
1 vote
1 answer
738 views

Node.js thread pool vs worker_thread

thread pool size can be determined with UV_THREADPOOL_SIZE. Worker_thread can create threads dynamically in runtime. Is this a only difference between thread pool and worker thread? Recently, I'm so ...
RunningLearner's user avatar
2 votes
1 answer
112 views

Exiting the stream NodeJS

Only 'text' is output to the console, but 'text2' and 'text3' are not output, because exit from the stream is faster. This is the most simplified code of the real project structure. I can't figure out ...
deekep's user avatar
  • 152
3 votes
0 answers
550 views

how to work with response object in nodejs stream, exceljs and worker thread

I am using worker thread and stream at same time in node JS project. At initial I was not able to pass res object through main process to worker thread. I saw many stackoverflow question and solution ...
sabin maharjan's user avatar
2 votes
0 answers
38 views

Using wokerpool on multi node.js processes running on the same server

I have a server with 6 CPU logical cores, there is 6 node.js (v 16) processes running express.js app within the server and managed by pm2 process manager, and I'm using Nginx proxy to load balance the ...
Basheer Shahrour's user avatar
1 vote
0 answers
454 views

Multiple node processes vs multiple worker threads

I have a project which I have to convert about 300+ different small application to node. The plan is to make one linux service per application, something like: Service 1 node /le-path/le-service1.js ...
Lucas Steffen's user avatar
1 vote
0 answers
1k views

Pass data between worker threads in node js

I have a nodejs application where I need to use a worker thread. The worker thread gets a message from the main thread. The message is sent inside a function in a class. I need to pass the instance of ...
Yael Tuvia's user avatar
0 votes
0 answers
228 views

Using Node JS worker threads for I/O intensive operation and make use of multiple core CPU

How effective is using worker threads for an I/O intensive application? Context- I am developing an application which sends out multiple API requests in parallel. There is a limit of how many requests ...
Mary123's user avatar
  • 11
0 votes
0 answers
1k views

How to run function in different thread with node.js

I have a REST API coded with Node.js and there is one route that applies NTFS Rights to folders. The request can take 1 second but can also last several minutes (it depends on the size of the folder). ...
jéjé's user avatar
  • 35
1 vote
1 answer
929 views

create worker file (worker threads nodejs)

I want to create a worker to send back an array as response to my main file, but I can't understand why the worker is not sending postMessage to main. Here is some dummy code to explain My main file: ...
DepletedKnowledge's user avatar
1 vote
1 answer
2k views

Cannot import modules in worker script

I'm new to using worker threads, thanks in advance for your help and time. Using node v12.22.4, mongodb v4.2.19 What I'm trying to achieve is: on client-side, user asks for a big export/download ...
iba's user avatar
  • 11
0 votes
0 answers
2k views

Importing/exporting Typescript type definitions in Node.js worker threads

I am learning Typescript and ran into the following problem with Node.js worker threads: In a tutorial I found this JS code to be implemented by the worker: //worker.js const {parentPort} = require(&...
Juno's user avatar
  • 271
2 votes
0 answers
484 views

Unable to import modules in node-worker-thread-pool

I am using node-worker-thread-pool package.I am unable to import certain node modules into my worker.ts, giving an error SyntaxError: Cannot use import statement outside a module. How to resolve this. ...
peaceMaker's user avatar
4 votes
1 answer
461 views

Why is all of my output appearing before each brute-force attempt when attempting to crack an ethereum keystore wallet file in node.js

I found a post describing how to recover an Ethereum wallet keystore by guessing a single password, however, it uses node synchronous code, and I'm trying to convert it into asynchronous code so that ...
loud_flash's user avatar
0 votes
0 answers
527 views

how to use threads and sleep() functionality with node.js

I am trying to learn node.js after python and trying to thread an infinitely running process in the background with a 2 minute sleep(). main.js const TeleBot = require("telebot"); const fun ...
Sumit Jaiswal's user avatar
0 votes
1 answer
363 views

Node.js: How to process objects of a big JSON file one by one to avoid heap limit errors

im trying to process a few hundreds of json.gz files using worker threads. at some point im getting js heap limit error due to 3 big files(about 3gb each unzipped). i tried to find a way to process ...
lightPT's user avatar
  • 58
0 votes
1 answer
552 views

How to properly handle worker_threads termination, when there are some node instances? (Like docker-swarm or Kubernetes cluster)

I'm creating worker_threads in node and I'm collecting them to custom WorkerPool. All workers are unique, because they have unique worker.threadId. My app have ability to terminate specific worker -- ...
Dmytro Telish's user avatar
1 vote
0 answers
137 views

Can a SharedArrayBuffer be picked up by garbage collection in Node?

I'm trying to build a Node application using worker threads, divided into three parts. The primary thread that delegates tasks A dedicated worker thread that updates shared data A pool of worker ...
Eric N's user avatar
  • 218
0 votes
1 answer
197 views

Undefined object properties inside callback function in Worker Thread's parentPort listener

I have a worker object something like this: const WorkerObject = { mapProp: new Map(), funA() { // some task }, funB() { // some task }, workerListener() { parentPort.on('...
alramdein's user avatar
  • 880
1 vote
3 answers
1k views

What is the importance of using WorkerThread annotation for a method that run in coroutine

I have noticed some methods in a project that I started to work recently as mentioned below. In this method functionality is executed in a coroutine. I wanted to know the purpose of the WorkerThread ...
pasanbuddhika's user avatar
1 vote
0 answers
334 views

What happens if @WorkerThread annonated function calls another function in android?

Which thread the subsequently called functions are executed? You may consider a function like the getNewsFeed() function inside the repository class given below - @Singleton class NewsFeedRepository @...
Anurag Pathak's user avatar
2 votes
1 answer
2k views

How to bundle worker_thread dependencies with webpack

I'm writing an electron application that uses electron forge for setup and configuration. The project uses Webpack 5 as a bundler and typescript as the development language. I'm having trouble running ...
Meerpohl's user avatar
  • 461
0 votes
0 answers
632 views

Worker Thread Implementation to connect SQL Server in Node JS

I need to implement Worker thread for an API to execute in concurrent way, API work is pull the data from SQL server, How to implement worker thread concept to connect SQL server and get the data from ...
Vignesh S's user avatar
0 votes
0 answers
586 views

Using worker_threads to loop through array of 300k items and run tests with jest

I have never used Workers with node before, but I have to run a series of tests with Jest with a large array of objects with size 300k+ items. I'd like to run workers with subportions of this array ...
SimoneMeta's user avatar
5 votes
1 answer
3k views

How to share context between worker threads

I would like to create a worker thread in a node.js app and pass the current context to the new thread, so I would be able to access my variables and functions within the new thread, Is there is a ...
dev3dev's user avatar
  • 138
4 votes
1 answer
8k views

Worker threads with ts-node

I am planning to have worker threads for socket.io rooms. I create a worker thread on the first connection to a room which then sets up firebase listeners. Unfortunately. I have common imports in the ...
Blaine's user avatar
  • 617