Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
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:

const { Worker } = require('worker_threads')
const worker = new Worker('./workerFile.js')

worker.on('message', msg => console.log(msg))

My workerFile.js

this.postMessage('hello world!')
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I had to import parentPort and then use it in workerFile.js:

const { parentPort } = require('worker_threads')
parentPort.postMessage('hello world!')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!