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

126
Visualizações
Stop chrome from reloading a tab in loop

I'm creating a Chrome extension and one of the actions is to reload the current tab after changing the URL. This is the code below:

submitChoices.addEventListener("click", async () => {
  let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
  let url = fieldChoices(tab); // This returns the new Url based on some choices
  chrome.tabs.query({ active: true, currentWindow: true }, function () {
    chrome.tabs.update(tab.id, { url });
    chrome.tabs.onUpdated.addListener(function () {
      chrome.tabs.reload(); // Issue seems to be here
    });
  });
});

The problem I'm having is that the chrome.tabs.reload(); seems to be stuck in a loop. The tab keeps on reloading and only stops after I change tabs or switch focus to another window/app. Any tips? Thank you!

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Your code is a bit confusing, with many parts you don't need. It keeps reloading because the onUpdated listener starts again every time. But you don't need the listener at all, and you don't need the second tabs.query that you are not even using:

submitChoices.addEventListener("click", async () => {
    let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
    let url = fieldChoices(tab); // This returns the new Url based on some choices
    chrome.tabs.update(tab.id, { url });
});
about 4 years ago · Santiago Trujillo Relatório
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