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

227
Views
Failed to fetch a worker script. VueJS application

I've been trying to use a SharedWorker in a Vue application, but faced the error "Failed to fetch a worker script".

I want to use a SharedWorker to get and post messages to WebSocket.

socketworker.js

const API_KEY =
  "<my api key>";
const socket = new WebSocket(
  `wss://streamer.cryptocompare.com/v2?api_key=${API_KEY}`
);

self.onconnect = e => {
  const port = e.ports[0];

  socket.addEventListener("message", evt => {
    if (evt.data) {
      port.postMessage(evt.data);
      return;
    }
  });
};

self.onmessage = e => {
  message = e.data;

  socket.send(message);
};

api.js

const socketWorker = new SharedWorker("./workers/socketworker.js", {
  type: "module",
  name: "socketWorker"
});

socketWorker.port.onmessage = e => {
 ...
}

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!