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

171
Vistas
Passing messages between service worker and popup.js

I'm currently writing a Chrome extension and I'm having trouble passing messages between the service worker and popup scripts. The service worker script is supposed to send a message to the popup script whenever a sign-out event is detected, but i keep getting the following error

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

The service worker invokes this method whenever a sign-out event is detected:

function inputController() {
  var store, remainingSessions, request, port;
  store = getObjectStore("readonly");
  request = store.getAll();
  request.onsuccess = function () {
    remainingSessions = request.result;
    port = chrome.runtime.connect({ name: "RemainingSessions" });
    port.postMessage(remainingSessions);
    console.log("msg sent");
  };
}

This is the code for popup.js

chrome.runtime.onConnect.addListener(function (port) {
  port.onMessage.addListener(function (remainingSessions) {
    console.assert(port.name === "RemainingSessions");
    console.log("Message received " + remainingSessions);
  });
});

I've looked around for the solution, but I haven't found much on this. Any advice or pointers on what I should change?

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