Blocked URL + Service Worker + Shield turn off

I have a website where I have a Service Worker and the blocked script don’t load because of weird error when the shield is off.

Fetch API cannot load https://stats.jcubic.pl/modules/base/js/owa.tracker-combined-min.js . Request mode is “no-cors” but the redirect mode is not “follow”.

Inside the service worker, I have this code (stripped no relevant code):

self.addEventListener('fetch', (event) => {
    if (filter(event.request) === false) {
        return;
    }
    const promise = new Promise(async (resolve, reject) => {
        const req = event.request;
        try {
            // Wayne logic with early return
            if (event.request.cache === 'only-if-cached' &&
                event.request.mode !== 'same-origin') {
                return;
            }
            
            fetch(event.request).then(resolve).catch(reject);
        } catch(error) {
            this._handle_error(resolve, req, error);
        }
    });
    event.respondWith(promise.catch(() => {}));
});

I’ve created an issue on StackOverflow

Fetch API cannot load . Request mode is “no-cors” but the redirect mode is not “follow”

but then realized that this works fine in Google Chrome, it only fails on blocked URL in Brave. So it must be a bug in Brave.

EDIT: I was inspecting the request object and it has those two values:

  • mode: "no-cors"
  • redirect: "error"

For non blocked URLs the redirect is "follow".