Production build unusable and Copilot console error

I started a project last year on Vaadin 24.3.5
I’ve recently started working on it again and updated the pom.xml Vaadin version to 24.6.1, Now I see this console error after sending a production build to gcloud
through the command line using mvnw package appengine:deploy -Pproduction

indexhtml-CEs0nSIY.js:175 Uncaught TypeError: Cannot read properties of undefined (reading 'push')
    at indexhtml-CEs0nSIY.js:175:1002

following the console link to the code I see

Vm = Mx([nw("copilot-main")], Vm);
const Cx = window.Vaadin
  , Sx = {
    init(i) {
        k3( () => window.Vaadin.devTools, t => {
            const e = t.handleFrontendMessage;
            t.handleFrontendMessage = n => {
                ax(n) || e.call(t, n)
            }
        }
        )
    }
};
Cx.devToolsPlugins.push(Sx);

which appears to be located in a generated source file that focuses on copilot

{project}\frontend\generated\jar-resources\copilot\copilot-Cj-G4kPi.js

currently my production build is not usable, the webpage shows up blank, and I can no longer access the login page.

I have tried to disable copilot, but this error persists…

application.properties

vaadin.copilot.enable=false
vaadin.devmode.devTools.enabled=false

Just to be sure: does your production profile exclude vaadin-dev?

https://vaadin.com/docs/latest/flow/production/production-build#excluding-development-server-module

That’s not enough. Compare your pom.xml with the latest download from start.vaadin.com - you are missing excludes

Good idea, but that did not change the problem nor error.
I tried the exact production profile from that latest start.vaadin.com
-oddly it launched a localhost browser 3 or more times while doing the production build, it didn’t do that before.
-the build still finished with success

[INFO] GCLOUD: To view your application in the web browser run:
[INFO] GCLOUD:   $ gcloud app browse
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

my new production profile based on your feedback:

<profile>
            <!-- Production mode is activated using -Pproduction -->
            <id>production</id>
            <dependencies>
                <!-- Exclude development dependencies from production -->
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-core</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-dev</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-maven-plugin</artifactId>
                        <version>${vaadin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-frontend</goal>
                                </goals>
                                <phase>compile</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

I’ll look closer at the rest of the pom.xml differences in about 12 hours.

I’m still running into the same problem.
I have used as much of the latest starter pom.xml as I could.
in the process flyway stopped working so I removed it.
here is my current pom.xml with the project name replaced with example and with all comments removed.

at this point mvn package and mvn install succeeds. my localhost debug build is working, but when I do a production build to gcloud, I get the same console error and same blank page as before.

At build time everything appears to be successful, that console error is the only clue I have.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.4.2</version>
    </parent>

    <groupId>example.example</groupId>
    <artifactId>example</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <java.version>17</java.version>
        <vaadin.version>24.6.4</vaadin.version>
        <db.image>postgres:16.6</db.image>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-bom</artifactId>
                <version>${vaadin.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.parttio</groupId>
                <artifactId>line-awesome</artifactId>
                <version>2.0.0</version>
            </dependency>
            <dependency>
                <groupId>com.google.cloud</groupId>
                <artifactId>spring-cloud-gcp-dependencies</artifactId>
                <version>5.0.1</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.google.api-client</groupId>
            <artifactId>google-api-client</artifactId>
            <version>2.7.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.apis</groupId>
            <artifactId>google-api-services-sheets</artifactId>
            <version>v4-rev20241008-2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client</artifactId>
            <version>1.36.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.http-client</groupId>
            <artifactId>google-http-client-gson</artifactId>
            <version>1.45.0</version>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jooq</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.ortools</groupId>
            <artifactId>ortools-java</artifactId>
            <version>9.9.3963</version>
        </dependency>
        <dependency>
            <groupId>org.parttio</groupId>
            <artifactId>line-awesome</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.cache</groupId>
            <artifactId>cache-api</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>com.hazelcast</groupId>
            <artifactId>hazelcast</artifactId>
            <version>5.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-testbench-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>32.1.2-jre</version>
        </dependency>
    </dependencies>

    <build>
        <defaultGoal>spring-boot:run</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>2.43.0</version>
                <configuration>
                    <java>
                        <eclipse>
                            <version>4.33</version>
                            <file>${project.basedir}/eclipse-formatter.xml</file>
                        </eclipse>
                    </java>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.vaadin</groupId>
                <artifactId>vaadin-maven-plugin</artifactId>
                <version>${vaadin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-frontend</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>2.8.1</version>
                <configuration>
                    <projectId>example</projectId>
                    <version>GCLOUD_CONFIG</version>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>production</id>
            <dependencies>
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-core</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-dev</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.vaadin</groupId>
                        <artifactId>vaadin-maven-plugin</artifactId>
                        <version>${vaadin.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>build-frontend</goal>
                                </goals>
                                <phase>compile</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <id>Vaadin Directory</id>
            <url>https://maven.vaadin.com/vaadin-addons</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>

Just a guess: you are not using clean… there is some stale env between a local run and a production run which interferes with your final artefact

I was not using clean, but trying clean just now didn’t seem to change anything in this case.

  • same successful build.
  • same blank page with the same error message in the console window.
  • same lack of errors in the server log.

here are the commands I used to attempt to build and deploy a clean production build.

mvn clean install
mvn clean package appengine:deploy -Pproduction

I don’t know appengine… so just a try

mvn clean install -Pproduction
mvn appengine:deploy

yes, my production profile excludes vaadin-dev

...
<profile>
            <!-- Production mode is activated using -Pproduction -->
            <id>production</id>
            <dependencies>
                <!-- Exclude development dependencies from production -->
                <dependency>
                    <groupId>com.vaadin</groupId>
                    <artifactId>vaadin-core</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>com.vaadin</groupId>
                            <artifactId>vaadin-dev</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
...

I didn’t know I could split that into 2 separate mvn calls.
Sadly, when trying that, the problem remains the same.

I have tried more ways to disable devTools as a work around to get a production environment working. no luck so far.

application.properties

vaadin.copilot.enable=false
vaadin.devmode.devTools.enabled=false
vaadin.devMode.devTools.enabled=false
vaadin.productionmode.devTools.enabled=false
vaadin.productionMode.devTools.enabled=false
vaadin.devTools.enabled=false

vaadin.productionMode=true

pom.xml commenting out a devtool dependency

<!--<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>-->

I have briefly tried going back to an older version of Vaadin like I was using last year, and that gives me other errors like failure to build frontEnd… even if i revert the entire code base.

Maybe I should start with the latest vaadin-start and see if i can deploy a production build of that to gcloud and then bring my project over a little at a time. besides that tedious idea I’m feeling pretty stuck.

Actually I just got something working

mvn clean package -Pproduction -Dvaadin.force.production.build=true
mvn appengine:deploy

using this build line seems to work.

Thank you both @knoobie and @marcoc_753 for pointing me in the right direction with the fact that development stuff was in my build, meaning it wasn’t a production build in some way for some reason.

there are probably some better changes that could be made, but I am happy enough changing my produciton build command to include the vaadin.force.production.build setting

1 Like