Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!