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

143
Views
Webworker not sending or receiving data properly

I'm trying to send a time delay to my webworker so it counts to 10 seconds, then calls the script on my main file but can't get it to execute properly.

main.js (path: public/javascripts/main.js)

const worker = new Worker('webWorker.js');
const timer = 5000;

window.onload = function() {
    worker.postMessage(timer);
}

worker.onmessage = e => {
    test();
}

function test(){
    console.log("timer worked");
}

webWorker.js (path: public/javascripts/webWorker.js)

this.onmessage = e => {
  const trigger = setTimeout(e.data);
  this.postMessage(trigger);
}

Where is this breaking down?

*Update - the issue is because my webWorker.js file isn't being found. Error GET http://localhost:3000/webWorker.js 404 (Not Found)

Have no clue why this is happening.

about 4 years ago · Juan Pablo Isaza
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!