Skip to content

Avoid Service Worker update issues on localhost - #1209

Merged
adamziel merged 1 commit into
trunkfrom
avoid-local-service-worker-update-issue
Apr 8, 2024
Merged

Avoid Service Worker update issues on localhost#1209
adamziel merged 1 commit into
trunkfrom
avoid-local-service-worker-update-issue

Conversation

@brandonpayton

Copy link
Copy Markdown
Member

What problem is it solving?

This PR fixes #1180 - Playground on localhost sometimes fails to load due to failed service worker updates from "localhost".

How is the problem addressed?

By switching from "localhost" to the explicit loopback address "127.0.0.1". This avoids the case where "localhost" does not directly resolve to a loopback address.

For reference:
https://w3c.github.io/webappsec-secure-contexts/#localhost

Section 6.3 of [RFC6761] lays out the resolution of localhost. and names falling within .localhost. as special, and suggests that local resolvers SHOULD/MAY treat them specially. For better or worse, resolvers often ignore these suggestions, and will send localhost to the network for resolution in a number of circumstances.

Given that uncertainty, user agents MAY treat localhost names as having potentially trustworthy origins if and only if they also adhere to the localhost name resolution rules spelled out in [let-localhost-be-localhost] (which boil down to ensuring that localhost never resolves to a non-loopback address).

Testing Instructions

Run npm run dev and confirm the new dev server URL is http://127.0.0.1:5400/website-server/ and that local Playground loads successfully in your browser.

@brandonpayton
brandonpayton requested a review from a team April 6, 2024 03:46
@brandonpayton

Copy link
Copy Markdown
Member Author

Note: I do not know what remoteDevServerHost is used for, but since it seems to also be used by npm run dev, I went ahead and changed that to "127.0.0.1" as well.

@adamziel

adamziel commented Apr 8, 2024

Copy link
Copy Markdown
Collaborator

Good fix @brandonpayton!

Note: I do not know what remoteDevServerHost is used for, but since it seems to also be used by npm run dev, I went ahead and changed that to "127.0.0.1" as well.

It's used for remote.html URLs.

@adamziel
adamziel merged commit 6a743a2 into trunk Apr 8, 2024
@adamziel
adamziel deleted the avoid-local-service-worker-update-issue branch April 8, 2024 08:25
@adamziel

Copy link
Copy Markdown
Collaborator

@brandonpayton I ran into that issue again on 127.0.0.1 – could be related to a stale service worker or could be an actual problem. Nothing actionable yet. Let's keep an eye on this.

CleanShot 2024-04-11 at 13 51 07@2x

@brandonpayton

Copy link
Copy Markdown
Member Author

@adamziel I ran into the same yesterday. I thought maybe it had something to do with a stale worker originally registered under "localhost". Unregistering the service worker and reloading the page fixed the issue, which seemed different than @mho22's experience here:
#1180 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants