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

208
Views
Can a service worker postMessage() directly to a shared worker client?

In a service worker, the client interface has postMessage() for talking to clients, which can be of type "window", "worker", or "sharedworker".

In "window" clients, the message event is sent to navigator.serviceWorker.controller. Example service worker code:

const windowClients = await clients.matchAll({ type: "window" });
windowClients[0].postMessage('Send this message to window.navigator.serviceWorker.controller');

But in shared worker clients, navigator.serviceWorker does not seem to exist. (This seems to change in a draft spec. Edit: And Safari.)

const sharedWorkerClients = await clients.matchAll({ type: "sharedworker" });
sharedWorkerClients[0].postMessage('Send this message to ???');

So where is the message event dispatched in the shared worker? Or is postMessage() a no-op here?

(There are workarounds like having the document transfer SharedWorker#port to the service worker. I'm wondering if there's a way to send messages directly.)

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!