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)