While diving into the codebase I had the following questions (see inlined comments):
Service worker registration
Why do we try to update right after registering the service worker?
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/context/service-worker-context.tsx#L20-L30
Upon SW registration, why are we holidng off resolving this async function with another promise that resolves if an update has been found?
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/service-worker-utils.ts#L4-L6
HeliaServiceWorkerCommsChannel
What's the use-case for EMITTER_ONLY? I couldn't find
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/lib/channel.ts#L7
(not sure if it's me, but I found the HeliaServiceWorkerCommsChannel to be rather hard to understand due to all of the abstractions there, maybe I'm missing something but I couldn't figure it out from reading the code)
Configuration
How was the config for this designed? (I failed to deduce the intricacies here by reading the code.)
- Why does the redirect page component use an iframe to show the config page, if it's only loaded at the point when the origin is the final one (the subdomain resolution url), can't you just render the config component without needed an iframe?
- I see that we have two source of truth for config, i.e.
indexedDB used in some places and localStorage in others. I figured this is because localStorage isn't available in the SW. We could simplify this by only using indexedDB, but I wanted to ask in case there was a reason.
For example, the config component calls both getConfig (indexedDB) and loadConfigFromLocalStorage:
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/components/config.tsx#L49
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/components/config.tsx#L68
While diving into the codebase I had the following questions (see inlined comments):
Service worker registration
Why do we try to update right after registering the service worker?
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/context/service-worker-context.tsx#L20-L30
Upon SW registration, why are we holidng off resolving this async function with another promise that resolves if an update has been found?
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/service-worker-utils.ts#L4-L6
HeliaServiceWorkerCommsChannel
What's the use-case for EMITTER_ONLY? I couldn't find
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/lib/channel.ts#L7
(not sure if it's me, but I found the HeliaServiceWorkerCommsChannel to be rather hard to understand due to all of the abstractions there, maybe I'm missing something but I couldn't figure it out from reading the code)
Configuration
How was the config for this designed? (I failed to deduce the intricacies here by reading the code.)
indexedDBused in some places and localStorage in others. I figured this is because localStorage isn't available in the SW. We could simplify this by only using indexedDB, but I wanted to ask in case there was a reason.For example, the config component calls both
getConfig(indexedDB) andloadConfigFromLocalStorage:https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/components/config.tsx#L49
https://github.com/ipfs-shipyard/helia-service-worker-gateway/blob/c7feb8884bac63beb0fb492bf4f16039c51c82f8/src/components/config.tsx#L68