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

299
Vistas
Getting: Uncaught (in promise) TypeError: Something went wrong while trying to open the window

This is my code in service worker for notification click event. All are working fine. But this console error Uncaught (in promise) TypeError: Something went wrong while trying to open the window. is appeared when I click the action button.

Why is this console error shown?

self.addEventListener('notificationclick', e => {
  const nf = e.notification;
  nf.close();
  if (!e.action) {
    if(nf.data && nf.data.url)
    {
      const url = nf.data.url;
      urltoopen(url,e);
    }
    return;
  }
  if(e.action === 'close'){
    return;
  }
  if(nf.data && nf.data.listurl)
  {
    const listurl = nf.data.listurl;
    Object.keys(listurl).forEach((k) => {
      if(k===e.action)
      {
        const actionurl=listurl[k];
        urltoopen(actionurl,e);
      }
    });
  }
});

function urltoopen(url,e) {
  const urlToOpen = new URL(url, self.location.origin).href;
  const promiseChain = clients.matchAll({
    type: 'window',
    includeUncontrolled: true
  })
  .then((windowClients) => {
    let matchingClient = null;

    for (let i = 0; i < windowClients.length; i++) {
      const windowClient = windowClients[i];
      if (windowClient.url === urlToOpen) {
        matchingClient = windowClient;
        break;
      }
    }

    if (matchingClient) {
      return matchingClient.focus();
    } else {
      return clients.openWindow(urlToOpen);
    }
  });
  e.waitUntil(promiseChain);
}
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