Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

298
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda