question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@PWA annotation does not create ServiceWorker and manifest

See original GitHub issue

Setup: Vaadin 14.0.2, Java 11, OpenSuse 15.2

Hello, I am not sure if this is a bug or a misconfiguration on my side. I am having an application with multiple servlets, one is working with Vaadin 14 where a PWA is developed.

The connection is running over HTTPS.

I use the following PWA annotation in my MainView:

@Route("main") @PWA(name = "Test", shortName = "Test") public class MainView extends AppLayout implements RouterLayout, BeforeEnter

If I access my application/sw.js there is no ServiceWorker found. Firefox also does not recognize the ServiceWorker. No installation window is shown. The Vaadin Bakery example worked fine in the browser. I could see the ServiceWorker in Firefox and access the .json over the application/sw.js.

Chrome Lighthouse confirmed that no ServiceWorker and manifest is running / was created.

My application is working fine, no errors there. Only the PWA part is not working.

I am not sure if only the ServiceWorker is effected by this or also the creation of the Webmanifest.

I would like to provide more information about this possible bug or the issue itself but I am not sure how.

If this is the wrong place for this ticket feel free to close it, please.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
denis-anisimovcommented, Oct 11, 2019

@mkemmerz if PwaConfiguration::isEnabled returns false then it means that PwaRegistry has been created with a null value for pwa parameter. It means that PWA annotation has not been found. Even though you have the annotation on the class the functionality which searches for it was not able to find it.

You mentioned here https://github.com/vaadin/flow/issues/6567#issuecomment-536868501 a custom servlet context class. I have a suspicion that the issue is caused by the custom servlet context. We have a code :

attribute = servletContext
                    .getAttribute(PwaRegistry.class.getName());

            if (attribute == null) {
                ApplicationRouteRegistry reg = ApplicationRouteRegistry.getInstance(servletContext);

                // Initialize PwaRegistry with found PWA settings
                PWA pwa = reg.getPwaConfigurationClass() != null ? reg
                        .getPwaConfigurationClass().getAnnotation(PWA.class)
                        : null;
                // will fall back to defaults, if no PWA annotation available
                try {
                    attribute = new PwaRegistry(pwa, servletContext);
                    servletContext.setAttribute(PwaRegistry.class.getName(),
                            attribute);

So the behavior may be cause by the behavior of the custom servlet context.

1reaction
joherikscommented, Oct 4, 2019

@mkemmerz The project setup seems quite complex. We would need a minimal project with the same setup to be able to reproduce the issue first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vaadin 14 - Service worker and manifest is not created
The issue was that my custom VaadinServlet did not recognize my @PWA annotation so I had to add it manually. public class VaadinFlowServlet ......
Read more >
PWA installation window not showing up in browser - Vaadin
I have the issue that no ServiceWorker is created, I think. The @PWA annotation is used once in my application but I can't...
Read more >
Vaadin 14 Service Worker And Manifest Is Not Created
The @PWA annotation tells Vaadin to create a ServiceWorker and a manifest file to fit under an icon when installed and should not...
Read more >
Building a Progressive Web Application with Create React ...
In this article, we will learn what exactly PWAs are and how we can configure our Create React App project into a custom...
Read more >
PWA with Create React App and service workers
By default, a service worker is kept on standby after it fetches content updates. As a result, users won't be able to see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found