Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

216
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda