vaadin/base-starter-flow-osgi

Production mode is not applied after using @VaadinMode(productionMode = true)

Closed this issue · 2 comments

pleku commented

Since #98, when adding @VaadinMode(productionMode = true) to FixedVaadinServlet, I still get in logs when starting the app:

...
[INFO] Started Jetty 9.4.31.v20200723 at port(s) HTTP:8080 on context path / [minThreads=8,maxThreads=200,acceptors=1,selectors=6]
[main] INFO com.vaadin.flow.osgi.support.ServletContainerInitializerClasses - Unable to detect used OSGi framework version due to null
[main] WARN com.vaadin.flow.server.DefaultDeploymentConfiguration - Following issues were discovered with deployment configuration:

WARNING: Vaadin is running in DEBUG MODE with debug features enabled, but with a prebuild frontend bundle (production ready).
When deploying application for production, disable debug features by enabling production mode!
See more from https://vaadin.com/docs/v14/flow/production/tutorial-production-mode-basic.html
Using Vaadin 15+ bootstrap mode.
 'index.html' is not found from '.\frontend\index.html'.
...

Also when adding the following code to MainView

    @Override
    protected void onAttach(AttachEvent attachEvent) {
        super.onAttach(attachEvent);
        add(new Span(""+attachEvent.getUI().getSession().getService().getDeploymentConfiguration().isProductionMode()));
    }

it reports false.

I think this is a know bug (not sure whether there is a ticket for this) in Flow.

productionMode is set in the token file during the starter project build.

@VaadinMode should apply the initial servlet parameter for the deployment configuration but it's ignored since
the parameter is already set from the token file.

I recall that I've reported this issue but I'm not sure whether I've made a ticket. I think I've made.

Now I recall the reason why I've removed productionMode parameter from VaadinMode (which has been added there initially by Stefan).
Exactly because it has no sense: the token file defines whether the app in the production mode or not.
So production mode currently may be changed only via maven plugin config parameter which writes production mode into the token file. And you may not change it during runtime because of bug in Flow.
This needs to be checked but I'm pretty sure this is the case.

In the base starter project we may remove productionMode parameter from VaadinMode for now since it doesn't work and is confusing.

pleku commented

Since the parameter is now removed, I think we can just close this. It is fine to have it the same way (as with everything else) by having to set the production mode during build time.