Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Conversation

@itschasa
Copy link

As mentioned in this comment on the commit:
6ddb73e#r140981857

This check is already performed in the fetch method:

Ultraviolet/src/uv.sw.js

Lines 50 to 58 in c34745f

async fetch({ request }) {
/**
* @type {string|void}
*/
let fetchedURL;
try {
if (!request.url.startsWith(location.origin + this.config.prefix))
return await fetch(request);

@incognitotgt
Copy link
Contributor

This is actually necessary.
It's weird

@itschasa
Copy link
Author

Does someone mind explaining?

@proudparrot2
Copy link
Contributor

In case someone who id using their own service worker or and didn’t include this check inside of it

@itschasa
Copy link
Author

In case someone who id using their own service worker or and didn’t include this check inside of it

Hasn't the check for it always been inside the service worker fetch function? I don't get how doing the check again before it enters the function's scope helps?

@Percslol
Copy link
Member

In case someone who id using their own service worker or and didn’t include this check inside of it

Hasn't the check for it always been inside the service worker fetch function? I don't get how doing the check again before it enters the function's scope helps?

no it was added recently because of some weird race conditions, its also good idiot proofing since anyone can modify the service worker and easily mess up this check somehow

@incognitotgt
Copy link
Contributor

race conditions my beloved

@itschasa
Copy link
Author

In case someone who id using their own service worker or and didn’t include this check inside of it

Hasn't the check for it always been inside the service worker fetch function? I don't get how doing the check again before it enters the function's scope helps?

no it was added recently because of some weird race conditions, its also good idiot proofing since anyone can modify the service worker and easily mess up this check somehow

Understood, I'll close the PR.

@itschasa itschasa closed this Apr 17, 2024
@itschasa itschasa deleted the patch-1 branch April 17, 2024 11:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants