Chrome Extension – listen to status “canceled” or “unknown” in network requests

My extension listens to certain network requests and responses, then logs them into the console using the chrome.webRequest api from the documentation. Here’s my background script that does all the listening.

The extension then console logs the requests. It’s a debugging tool. You can see that on response, I pass the status code along to be logged. That status code is for me to be able to indicate for the user that their request has failed or succeeded in the console log.

Now, I want to be able to do the same for the requests that were cancelled or the status of which is unknown to the browser.

Here are the examples of how they look like (sorry for the quality, got it from the user):
enter image description here

I looked for the callback, but I couldn’t easily find it. Not sure if Chromium is nice enough to provide those.

Now I think of two options if there’s indeed no convenient callbacks:

  1. Try using the performance.getEntriesByType(“resource”) but I believe the performance API doesn’t provide the statuses of the requests sent.

  2. I could implement some weird awkward logic… I’m already storing the requests sent in a map onBeforeRequest. So I could just add the timestamp to each of them, then poll them and if I see a request there that is like N seconds old (probably 1 second, or I’ll make a config for it), I would just log it with an error saying something like: “received no server response” and remove it from the map. I don’t like the idea of manual polling though. Always feels like a hack.