Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
68 views

How to test a worker thread in NodeJS?

I have a node script that uses a worker thread. I want to test it with Jest. The file is called, but the code is never executed. Here is the function that calls the worker: // index.ts function foo(){...
DoneDeal0's user avatar
  • 6,167
0 votes
0 answers
30 views

Use native module in worker_threads in electron

We are using better-sqlite3 in our project. And we are using it in a worker thread. It is a native module that is built on compile time (.node file). In our development environment it's possible to ...
baklap's user avatar
  • 2,173
0 votes
0 answers
137 views

How to Parallelize Puppeteer Tasks Using Worker Threads in Node.js?

I'm working on a Node.js project where I need to run multiple Puppeteer instances in parallel to scrape data from a website. I've read that using worker_threads can help achieve this by running tasks ...
Ilya's user avatar
  • 55
0 votes
0 answers
65 views

How to perform socket operation on a worker thread in Javascript?

I am trying to implement WebRTC signaling using socket.io. Since handling new connections and handling different events for signaling will take a huge toll if performed on a single thread, I am ...
Aamir's user avatar
  • 13
1 vote
0 answers
153 views

nodejs write to same file with multiple worker threads concurrently

I'm wondering whether we can write to the same file in multiple worker threads concurrently . I've goolged around, and many people say that this operation may cause file write collisions, so I write ...
Jess's user avatar
  • 650
0 votes
0 answers
75 views

Using server-side streaming RPC in tonic, is it safe to do heavy compute without spawn_blocking?

When doing server-side streaming in tonic, the generated async function is expected to return something which implements Stream. If I construct my stream by taking a receiver and then calling .map(...
dspyz's user avatar
  • 5,460
0 votes
0 answers
46 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
48 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
170 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
103 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
162 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
38 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
  • 189
1 vote
1 answer
1k 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
  • 21
1 vote
0 answers
269 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
  • 576
1 vote
1 answer
306 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
297 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
1k 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
210 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
225 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
113 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
266 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
  • 471
0 votes
2 answers
833 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
  • 24
1 vote
0 answers
287 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 ...
zleyyij's user avatar
  • 36
0 votes
1 answer
450 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
1k 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
  • 76
0 votes
0 answers
306 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
385 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
  • 430
0 votes
0 answers
180 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
2 votes
1 answer
2k 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
  • 345
1 vote
1 answer
1k 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
134 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
  • 162
3 votes
0 answers
708 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
44 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
569 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
279 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
  • 41
0 votes
0 answers
2k 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
1k 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
  • 299
2 votes
0 answers
507 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
481 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
593 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
394 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
659 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
163 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
211 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
  • 881
1 vote
3 answers
2k 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
448 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
  • 471