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

143
Visualizações
Hold HTTP request with chrome.webRequest until some async function is resolved

Basically I need to stop an HTTP request, send it to an app to determine weather or not it should be blocked and then take the appropriate action. A simplified version of the code would look something like:

chrome.webRequest.onBeforeSendHeaders.addListener( async details => {
        let policy = await getPolicy(details); 
        return {cancel: result}
    },
    {urls: ["<all_urls>"]},
    ["requestHeaders", "blocking"]
);

with the getPolicy function sending the info to a policy server to determine weather or not to block the request and then return a boolean result. The problem boils down to while I am waiting for a policy result the listener doesn't continue to hold the request but just allows all request through before a result is returned. I based this current code off of the similar question here: https://stackoverflow.com/a/57301607/16531716 That answer however doesn't seem to actually work. (I am using Manifest V2 because that is the only way I can use the blocking permission. MV2 doesn't normally support async operations but I'm also using the Mozilla polyfill module to add them so that isn't the issue)

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