Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't register service worker when running DevTools locally #3476

Merged
merged 2 commits into from Nov 1, 2021

Conversation

elliette
Copy link
Member

Adds a check to see if DevTools is running locally in index.html, which is determined by:

  • the host name is localhost OR
  • the index.html file is called index.ddc.html

If so, we skip the service worker registration step (before, this would fail after 4 seconds).

I've also caught any error coming from registering the service worker, and logging it to the console as a warning.

function waitForActivation(serviceWorker) {
serviceWorker.addEventListener('statechange', () => {
if (serviceWorker.state == 'activated') {
if (window.location.hostname === 'localhost' ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking for localhost doesn't seem safe. Could easily be running devtools from localhost in a release build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SG, modified to just check for index.ddc.html

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@elliette elliette merged commit c266e5b into flutter:master Nov 1, 2021
@elliette elliette deleted the service-worker-registration branch December 24, 2021 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants