Vite Import Error During Hotswap (Vaadin 25.0.6)

Vaadin Dev Mode – Vite Import Error During Hotswap

I am running into a persistent Vaadin dev mode issue in a Gradle-based Vaadin 25 + Spring Boot project. After a hotswap-triggered reload, the frontend enters a broken state and begins logging the same Vite import errors repeatedly until I manually terminate the application.

Environment

  • Vaadin 25
  • Spring Boot
  • Gradle project
  • Dev Mode / Vite
  • Local Windows development environment
  • Hotswap agent enabled

Problem

After a code change triggers hotswap, the frontend starts failing with missing generated file errors. Once it starts, the app appears to enter an infinite loop of these errors and does not recover on its own. The only way out is to kill the application and start it again.

A restart temporarily fixes the problem, but the issue comes back later on another hotswap.

Main Error

[vite] Internal server error: Failed to resolve import "./index" from "src/main/frontend/generated/vaadin.ts". Does the file exist?

Plugin: vite:import-analysis
File: src/main/frontend/generated/vaadin.ts:50:7

42 | import "@vaadin/icons/vaadin-iconset.js";
43 | import "@vaadin/icon/vaadin-icon.js";
44 | import "./index";
     |        ^
45 | import "./vaadin-react.js";
46 | import "Frontend/generated/jar-resources/vaadin-dev-tools/vaadin-dev-tools.js";

[vite] (client) Pre-transform error:
Failed to load url /generated/vite-devmode.ts (resolved id: /generated/vite-devmode.ts).
Does the file exist?

[vite] (client) Pre-transform error:
Failed to resolve import "./index" from "src/main/frontend/generated/vaadin.ts"

Infinite Loop Behavior

Once the issue occurs:

  1. Hotswap reloads backend classes
  2. Vite reports missing generated frontend files
  3. The same errors repeat continuously in the dev server logs
  4. The application never recovers
  5. The only solution is to kill the process and restart

It appears that something under: src/main/frontend/generated/ is being deleted or left in an inconsistent state after hotswap. When that happens, Vite attempts to load files that no longer exist, and Vaadin never successfully regenerates them.

Troubleshooting Already Done

I have already tried the following multiple times:

  • Running Vaadin clean tasks
  • Rebuilding the project from scratch
  • Regenerating frontend artifacts
  • Deleting node_modules and rebuilding
  • Recreating the development environment entirely
  • Following the Vaadin 25 Gradle setup documentation step-by-step

None of these resolved the issue.

Tested on Multiple Machines

To rule out a local configuration problem, I tested this setup on multiple development machines. The behavior is consistent across them.

What makes this particularly confusing is that hotswap worked reliably in Vaadin 24 on the same machines and similar project structures.

The issue only started appearing after moving to Vaadin 25, which now uses the newer Vite-based dev mode tooling.

I noticed that a similar bug was reported in Vaadin 24.6.1 and was fixed. I am unsure why I am seeing this again.

Does anyone have insight on this?

Thanks
Ani

The first thing that comes to mind is that during hotswap for some reason vaadinPrepareFrontend task is called (as in the linked issue). Can you verify that this is not happening?

It does appear that vaadinPrepareFrontend is being run as part of the hotswap operation. Is there a way to prevent this?

I’d say that Hotswap agent cannot run Gradle since it does not know anything about it.
The execution is most likely triggered by the IDE for some reason, e.g. some run configuration option.